If I have the following code:
lock(SyncRoot){ return value; }
Will the SyncRoot be unlocked before the return statement?
I tried walking through the code in VS2005, but it doesn’t actually show one way or another. It looks like it DOES unlock it, but I want to make sure.
Yes it does unlock no matter how you exit the block (i.e. return, break, throw, etc).
See MSDN – lock statement for more details: