Yes. I'm sure it seemed like a good idea at the time, but [ThreadStatic] lulls developers into a false sense of security. ThreadStatic fields have many disadvantages of global variables, and the only advantage (different threads have their own instances of a global thing) has a corresponding disadvantage (this thing disappears if you switch threads). This is not a win. The globals suck, and the flow-static globals suck in every bit in the same way as a regular one.
Iām working on a rather large code base, several years with dozens of developers (maybe a couple of hundred if you could leave the team in the last few years), and [ThreadStatic] will regularly bite us. We have tons of code that uses global ThreadStatic, which, of course, breaks if you do something in the workflow. As I said, Iām sure that at the time it seemed like a good idea ... but now it cost us much more than it ever bought us.
An alternative could be passing the same object (HttpContext, Transaction, etc.) for each method that depends on it. This requires more typing, but in my not very modest opinion, in the end it is still better.
source share