I want to store per-thread data in an ADO.NET Data Service. Is it safe to use the ThreadStatic attribute on my thread-specific static variable, or will I run into problems? My concern is that my ThreadStatic variable(s) won't be garbage collected after the request is completed and the thread dies.
If there's a better way to do what I'm...
I've recently encountered an issue with the multi-threaded nature of the BizTalk Mapper and how it handles external assemblies.
As this quote from MSDN indicates:
Important Any code written in an
external assembly for use in a
scripting functoid needs to be thread
safe. This is required because
multiple instances of a map c...
Is there a way to make newly-spawned threads inherit the values of ThreadStatic state (or something like it) on their parent threads? I would like to use this (or something like it) to implement "dynamically scoped" special variables that contain operation/task context information to use for tracking/logging, etc. Is this a reasonable ...
I have seen lots of documentation on how Agile Asp.Net Request handling is? I want to know is the case same with WCF Request handling. Can we rely on the fact that the Thread that starts Wcf request handling will finish it?
I am maintaining a Wcf Application where at lots of places ThreadStatic variables are used. Although the code is w...
System.Transactions notoriously escalates transactions involving multiple connections to the same database to the DTC. The module and helper class, ConnectionContext, below are meant to prevent this by ensuring multiple connection requests for the same database return the same connection object. This is, in some sense, memoization, altho...
With the ThreadStatic attribute I can have a static member of a class with one instance of the object per thread. This is really handy for achieving thread safety using types of objects that don't guarantee thread-safe instance methods (e.g., System.Random).
It only works for static members, though. Is there any straightforward way to d...
So I have a method that gets a Dictionary of List<myObj>, then cycles through the keys of the dictionary and passes each List<myObj> to a separate thread.
Here is some Code / Psuedo-Code:
public static void ProcessEntries() {
Dictionary<string, List<myObj>> myDictionary = GetDictionary();
foreach(string key in myDictionary.ke...
I have veeeeryyy basic singleton in asp.net web application:
[ThreadStatic]
private static BackgroundProcessManager2 _Instance;
public static BackgroundProcessManager2 Instance
{
get
{
if (_Instance == null) // **
{
_Instance = new BackgroundProcessManager2();
}
return _...
I recently read this post about poor performance of fields marked ThreadStatic - they're apparently 60x slower than normal field access. Does .NET 4's ThreadLocal< T > perform any better?
Are there any alternatives that offer high performance thread-specific storage?
...