- Thanks received
- 0
ASB said:Fair comment, but there are of course differing views.
In this particular case the method has to retain state. Now I can retain it as a member in the class for example. However the issue with that is scope.
Since it is only valid within the context of the method then I would prefer to reduce visibility to that method. If it's a member variable it's all too easy for somebody to come along and misuse it at a later date. Hence the thought of the static. Something I know you cannot do in C# (or couldn't).
In which case as Weltchy suggested you need to store the state within the currently executing thread. In Java (sorry not a .NET developer) you have a ThreadLocal object (assuming it's the same idea as a ThreadStatic object) where you can store information that is specific to the current thread. If the thread re-enters the method it will be able to pick up it's own stored state, and any other thread would have it's own individual state.


