XPhaktor,
You will have no choice but to use a class level variable to handle
this. C# doesn't support local static variables.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
"XPhaktor" <(E-Mail Removed)> wrote in message
news:9ED003EF-7E4F-44C3-A907-(E-Mail Removed)...
> In C#, how do I replace using VB local static variable declarations to
> handle
> method reentrancy. Note, if you use a class-scope variable instead of a
> local
> one, then you run the risk of inadvertently changing the variable's value
> in
> another method that is performing the same technique.
>
> The Interlocked.Exchange class uses a class-scope class attribute.
>
> Reentrancy is not just a problem for user events (e.g., overzealous users
> double-clicking on a button). Reentrancy is also a problem in systems that
> use concurrency, where methods may be overstacked in the call-stack.
>
> VB example:
>
> Private Function foo()
> Static st_blnInHere As Boolean
>
> Try
> '$ To avoid reentrancy:
> If st_blnInHere Then
> Exit Try
> Else
> st_blnInHere = True
> End If
>
> '$ critical code here...
>
> st_blnInHere = False
>
> Catch ex As Exception
> st_blnInHere = False
> Finally
> End Try
> End Function
>