title: .NET - Thread synchronization
body: <p>I've been working on a thread which will live as long as the application is running, and runs at a interval of 500ms. I noted that I could be uselessly processing if there's nothing in the queue for it to process, so I went around looking at some sources I had locally, and I found an example close to mine, but it's in Java.</p>
  
  <p>The example had this:</p>
  
  <pre><code>synchronized(this) {
      try {
          wait();
      } catch (InterruptedException e) {
          cleanup();
          break;
      }
  }
  </code></pre>
  
  <p>Inside a while loop which goes on forever. </p>
  
  <p>The thread has this to notify the wait:</p>
  
  <pre><code>synchronized(this) {
      notifyAll();
  }
  </code></pre>
  
  <p>This was inside the enqueue thread.
  I'd also like you to note that the class inherits Runnable.</p>
  
  <p>Could anyone quickly explain the corresponding functions in C#? And maybe an example if you could!</p>