ThreadPool bug in CLR 2.0 SP1

Shortly after the release of CLR 2.0 SP1 (a.k.a. Orcas or .NET 3.5), several customers noticed some very odd behavior in the ThreadPool.  The ThreadPool is supposed to create threads as fast as possible, up to the current setting for MinThreads – but it turns out that if you queue workitems very quickly (like in…

3

When should you call RegisteredWaitHandle.Unregister?

The managed ThreadPool provides a way to asynchronously wait for WaitHandles, via ThreadPool.RegisterWaitForSingleObject. This method returns a new instance of RegisteredWaitHandle, which has a single method: Unregister.  It’s obvious from the name that this will cancel a pending wait operation.  What’s not obvious is that even after a registered wait has completed, you should still…