is it ok to do stuff like this - will var locker be unlocked before Method() is called from the inside of the Method()
private void Method()
{
lock (locker)
{
// do some stuff
// ...
// ...
// ...
if (testVar = someVar)
{
Method();
}
}
}

recursive locked methods
KJBalaji
Locks are re-entrant, meaning once a thread has the lock it can enter the lock statement as many times as it wants. So locker will not be unlocked before method is called inside of method but the thread can pass through the lock statement again.
Mark.
redshock
Hi,
"lock" is for multithreading issues,
When you "lock" some object then EXCEPT the thread which has aquired lock on the object, NO OTHER thread will be able to aquire lock on that object TILL first thread release the lock.
So, in your case, its the same thread which again and again entering the lock so its not like re-locking, but once the lock has been aquired, till you finish the method executions it will NOT release the lock. Its not again re-locking but for the same thread, the lock aquired will work as single time locking.
So, till the complete cycle of recursive calling is not finished once its aquire lock, IT WILL NOT UNLOCK it NOR RE-LOCK it.
HTH,