title: using nested/outer lock c#
body: <p>Is it ok to write such a code:</p>
  
  <pre><code>lock(syncObject) {
      try {
  
          do {
              // do some computations
  
              if(this.isStopped) break;
              Thread.Sleep(30000);
  
          } while(true);
      } 
      catch(Exception ex) {
          Logger.Log.Warn(ex);
      }
  }
  </code></pre>
  
  <p>or would it be better to put this piece inside a <code>while</code> loop:</p>
  
  <pre><code>// ...
  do {
      // do some computations
  
      lock(syncObject) {
          if(this.isStopped) break;
      }
      Thread.Sleep(30000);
  
  } while(true);
  // ...
  </code></pre>