6

Possible Duplicate:
In c# does a locked object stay locked if an exception occurs inside it?

What happens when you have code such as this

  lock(myLock)
  {
    try{
      //some code
    }catch(SomeException e)
    {
      throw e;
    }
  }

Will myLock get released properly? I have a situation where this is necessary, so how would I go about it short of writing my own Lock that has an explicit Release method I can call in the try catch's finally method.?

Community
  • 1
  • 1
Vort3x
  • 1,778
  • 2
  • 20
  • 37

0 Answers0