Questions tagged [threadstatic]

An attribute indicating that the value of a static field is unique for each thread.

An attribute indicating that the value of a static field is unique for each thread.

References

55 questions
1
vote
2 answers

BizTalk mapper and the [ThreadStatic] attribute

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…
David Hall
  • 32,624
  • 10
  • 90
  • 127
1
vote
1 answer

ASP.NET, WCF and per-operation static variables - how to use them safely?

I have a WCF service and I have the following (simplified) class: public class PerOperationSingleton : IDisposable { private static bool _hasInstance = false; public PerOperationSingleton() { if(_hasInstance) throw…
JustAMartin
  • 13,165
  • 18
  • 99
  • 183
0
votes
1 answer

ASP.NET MVC 5 - can the current thread change during single http request?

Sometimes (randomly) I'm faced with my [ThreadStatic] property is null, though it is definitely initialized in the beginning of the request.
gustav
  • 119
  • 13
0
votes
1 answer

Object reference error while instantiating non static class in multiple threads

I am using C# and NUnit framework for executing multiple test in separate threads simultaneously. I want to record the time between certain actions and have created an ActionTimeHelper class for the same. Below is the code for the class and the…
test_user
  • 69
  • 1
  • 7
0
votes
1 answer

library using threadstatic to be used in asp.net

I have created a library which is using threadstatic variables to be used by various classes of the same library. Once initialized for a thread, all these classes work together to achieve a task using these variables. Now i need to use this same…
bjan
  • 21
  • 7
0
votes
1 answer

ThreadStatic member lose value on every page load

I have veeeeryyy basic singleton in asp.net web application: [ThreadStatic] private static BackgroundProcessManager2 _Instance; public static BackgroundProcessManager2 Instance { get { if (_Instance == null) // ** { …
st78
  • 8,028
  • 11
  • 49
  • 68
0
votes
1 answer

Creating thread safe variable in c#

I have a static variable which is accessed by multiple threads in multiple object. The problem is if I set value in one thread it does not reflect in another thread. To resolve the issue I made the variable thread static but still the value…
user2692032
  • 771
  • 7
  • 26
0
votes
1 answer

How to Use Powershell to Kill threads of a specific processID

well this has been bugging me for a couple of days on and off. I am at a clients site where they have a number of bespoke, written in house, services running on a Windows 2008R2 IIS server. The problem is that a couple of these services keep…
Wynn
  • 43
  • 3
  • 8
0
votes
2 answers

Apply [ThreadStatic] attribute to a method in external assembly

Can I use an external assembly's static method like [ThreadStatic] method? Here is my situation. The assembly class (which I do not have access to its source) has this structure public class RegistrationManager() { private RegistrationManager()…
Sen Jacob
  • 3,384
  • 3
  • 35
  • 61
-2
votes
2 answers

.Net Core 3.1.6 ThreadLocal / ThreadStatic

Quick question regarding ThreadStatic and ThreadLocal in C#, specifically .Net Core 3.1.6.. I would rather not post the exact example but it's very similar to this: [ThreadStatic] static readonly Object LocalObject = new Object(); I then access…
Jay
  • 3,276
  • 1
  • 28
  • 38
1 2 3
4