When I work with threadstatic variables in my background jobs , strange things happen on the production system which is has more than 15 queues and 40 workers.
I think this is because of the ThreadPool is used internally as stated below
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. A method that accesses a field that is marked with the ThreadStaticAttribute attribute could encounter different data depending on which thread pool thread executes it.
Can somebody confirm that or do you have any explanation?