<p>The thing is I've been using the <a href="http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx" rel="noreferrer">lock statement</a> to protect a critical part of my code, but now, I realize I could allow concurrent execution of that critical code is some conditions are met.<br>
Is there a way to condition the lock?</p>

```
```
Action doThatThing = someMethod;

if (condition)
{
  lock(thatThing)
  {
     doThatThing();
  }
}
else
{
  doThatThing();
}
```
```