When I go, I’m going to take it with me

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.


This entry was posted in Computers and Internet. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s