I suppose it’s obvious when you think about it, but when you ask the CLR to run a method on the thread pool there’s a lot of context that you’d like to be taken across to the new thread – things like CAS permissions and identity need to be captured in the current thread and added to the ThreadPool thread while the method is executed.
In the following code, for example, you can see the logical call context is copied across to the executing method’s ThreadPool thread.
This is all implemented in terms of ExecutionContexts, one of which is captured when the method is queued.
Looking at the Capture method, you can see all of the work that it does.
And using Reflector, we can see lots of places where the ExecutionContext is captured and then flowed.