background preloader

Threading

Facebook Twitter

MP-ACID. Moores law reached its end with single core performance a few years ago.

MP-ACID

Since then only the amount of memory and number of cores raised significantly. Classical programing paradigms can not cope with this problem. Especially as garbage collector can not be fully concurrent, if variables are mutable. Immutable variables and pure functional programming are a pain in the ass, if you ask an average programmer. But average programmers enjoy concepts like node-js, despite node-js being JavaScript, single threaded and slow as a hell.

ThreadStatic, CallContext and HttpContext in ASP.Net. Summary:Even if you think you know what you're doing, it is not safe to store anything in a ThreadStatic member, CallContext or Thread Local Storage within an ASP.Net application, if there is the possibilty that the value might be setup prior to Page_Load (eg in IHttpModule, or page constructor) but accessed during or after.

ThreadStatic, CallContext and HttpContext in ASP.Net

[Update: Aug 2008 In view of the fairly large number of people continuing to link to this post I feel the need to clarify that this thread-swapping behaviour happens at a very specific point in the page lifecycle and not whenever-it-feels-like-it. My wording after the Jef Newson quote was unfortunate. That aside, I've been immensely gratified (and flattered) by the number of times I've seen this post cited within design discussions around dealing appropriately with HttpContext.

A tale of two techniques: The [ThreadStatic] Attribute and System.Web.HttpContext.Current.Items.