I have code here that works as expected when I install and run it on my own computer, Windows 7, but when I run it on other servers (2003 and 2008), it is not. The code is from the .NET4 WCF Service Library, which I use in a Windows service. Here it is simplified.
public void monitorQueueAndDoStuff() { MonitorRetryQueue(); MonitorMainQueue(); } private void MonitorMainQueue() { Log.Info("MonitorMainQueue called"); Task.Factory.StartNew(() => { Log.Info("new thread monitoring queue"); // ...NMS stuff while (!stopped) { ITextMessage mess = null; mess = blockingMessageCollection.Take(); sendToQueue(mess); } } } }); } private void MonitorRetryQueue() { Task.Factory.StartNew(() => { //...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); } } } }); }
Threads must introduce loops to do some work. The main block is blocked on the BlockingCollection. Now it creates both tasks, but it only enters the second, it never prints a βnew thread monitoring queueβ in the log. I canβt understand why not. I tried remote debugging, but since it never goes into code, I could not see anything.
I did not find anything that could change the behavior of the code on the deployed server. Can anyone here have a clue? Any settings in a Visual Studio project?
source share