【发布时间】:2012-08-17 17:09:44
【问题描述】:
我有一些代码在我自己的计算机 Windows 7 上安装/运行时按预期工作,但当我在其他服务器(2003 和 2008)上运行时却没有。该代码来自我在 Windows 服务中使用的 .NET4 WCF 服务库。在这里,很简单。
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);
}
}
}
});
}
线程应该进入循环来做一些工作。 BlockingCollection 上的主要块。 现在,它创建了两个任务,但它只进入第二个,它从不在日志中打印“新线程监控队列”。我不明白为什么不。我尝试了远程调试,但由于它从不进入代码,我看不到任何有价值的东西。
我没有发现任何会改变已部署服务器上代码行为的东西。这里有人可能有线索吗? Visual Studio 项目中的任何设置?
【问题讨论】:
标签: c# visual-studio-2010 .net-4.0 task-parallel-library