I am working with Threads. I am unsure if the flag ThreadStatic Is needed or not. In any thread anyway a can access the simple type of boolean.
When working over several threads what is enought:
Private _ImageToggle As Boolean
or
<ThreadStatic()> Private _ImageToggle As Boolean
* MY INTERPRETATION of Marc Gravells answer *
If there are several instances which each are using multithreading, the “Threadstatic” flag can be a solution to use a shared value. As far as I understood rightnow for basic types it does never makes sense.
Since it isn’t
static(Sharedin VB),[ThreadStatic]has no effect. No; it does not need this.When applied to a static field,
[ThreadStatic]means that each thread is talking to a different value (essentially it becomes thread-local-storage). This is double-edged, as any async-based (including ASP.NET and WCF) code needs to be really careful. In general I would avoid this flag – it is better to use an instance member and pass that around (between threads) as the context.