title: Task.Factory.StartNew not executing the task when deployed
body: <p>I have some code here that works as expected when I install it / run it on my own computer, Windows 7, but when I run it on other servers (2003 and 2008) it does not. The code is from a .NET4 WCF Service Library that I use in a Windows service. Here it is, simpllified.</p>
  
  <pre><code>public void monitorQueueAndDoStuff() {
    MonitorRetryQueue();
    MonitorMainQueue();                
  }
  
  private void MonitorMainQueue() {
    Log.Info("MonitorMainQueue called");
    Task.Factory.StartNew(() =&gt;
    {
      Log.Info("new thread monitoring queue");
      // ...NMS stuff
  
          while (!stopped) {
            ITextMessage mess = null;
              mess = blockingMessageCollection.Take();
              sendToQueue(mess);
          }
        }
      }
    });
  }
  
  
  private void MonitorRetryQueue() {
    Task.Factory.StartNew(() =&gt;
    {
      //...NMS stuff
          consumer.Listener += new MessageListener(OnRetryErrorMessage);
          Log.Info("new thread monitoring second queue");
  
          //need to be constantly up for the consumer to hang around
          while (!stopped) {
            Thread.Sleep(1000);
          }
        }
      }
        });
  }
  </code></pre>
  
  <p>The threads should enter loops to do some work. The main one blocks on a BlockingCollection.
  Now, it creates both tasks but it only enters the second, it never prints "new thread monitoring queue" in the log. I cannot grasp why not. I tried Remote Debugging but as it never enters the code I couldn't see anything of value.</p>
  
  <p>I haven't found anything that would change the behavior of the code on the deployed server. Anyone here might have a clue? Any settings in the Visual Studio project?</p>