If I set the CurrentCulture
of a thread pool thread, what happens when the thread finishes execution and gets returned back to the thread pool? Does it get its CurrentCulture
reset back to the default (whatever that may mean), or will it retain the culture I have set on it?
I'm hoping that the framework resets the thread to a default state to guard against this, but cannot find any documentation to this effect. The closest I have found is from the MSDN docs for ThreadPool:
When the thread pool reuses a thread, it does not clear the data in thread local storage or in fields that are marked with the ThreadStaticAttribute attribute. Therefore, data that is placed in thread local storage by one method can be exposed to any other method that is executed by the same thread pool thread.
This seems to indicate that the thread is not reset when it is returned.
I have tried some sample code to try to test this, and it does seem that the culture is reset, but I am not convinced that I am testing this behaviour correctly as I think I am only using a small subset of the ThreadPool's threads, and so cannot be sure I'm testing a thread that has already had it's culture set.