ThreadPool.QueueUserWorkItem returns false on failure!

ThreadPool.QueueUserWorkItem is commonly used to execute some task in the background at a later point in time using a thread from the thread pool. If you read the MSDN documentation carefully, you'll note it says:

Return Value

true if the method is successfully queued; otherwise, false.

Exception type Condition

ApplicationException

An out-of-memory condition was encountered.

Wow! It might just return false if it fails instead of throwing an exception. This must be one of those early APIs that they didn't get right the first time and couldn't change later for legacy reasons. It also uses ApplicationException, which seems very odd. I rarely see code that checks the result, including the sample code on the MSDN documentation site! This could cause unexpected failures in your application.