At the moment, I have some functions which look like this:
private bool inFunction1 = false;
public void function1()
{
if (inFunction1) return;
inFunctio
Instead of using a bool and setting it directly, try using a long and the Interlocked class:
long m_InFunction=0;
if(Interlocked.CompareExchange(ref m_InFunction,1,0)==0)
{
// We're not in the function
try
{
}
finally
{
m_InFunction=0;
}
}
else
{
// We're already in the function
}
This will make the check thread safe.