title: Weird order of execution in threaded program
body: <p>I'm attempting to execute a manager as thread by the code below. The weird thing that happens is that, as I dubug the code step by step, it seems that the <code>Stop()</code> method is called <strong>before</strong> the <code>Start()</code> method in the manager.</p>
  
  <pre><code>MyManager manager = new MyManager();
  Thread thread = new Thread(manager.Start);
  thread.Start();
  
  while (Directory.GetFiles(pathToFiles).Length &lt; 5)
    Thread.Sleep(1000);
  
  manager.Stop();
  thread.Join();
  </code></pre>
  
  <p>It's even weirder than that! <strong>Sometimes</strong> the execution order is as it's supposed to be. Then, as if something clogs the sanity, the breakpoint inside the <code>Stop()</code> method is hit <strong>first</strong> and the one in the <code>Start()</code> method later.</p>
  
  <p>I'm suspecting something more intricate because on occasion, the program doesn't even hit the breakpoints while executed (and I execute in exact the same way)!</p>
  
  <p>Not being a guru on threaded development, I need to know how to trouble-shoot this.</p>