我有一个WCF Windows服务,OnStart功能:
protected override void OnStart(string[] args)
{
System.Diagnostics.Debugger.Launch(); //added for debugging for now
_Host = new ServiceHost(typeof(Service));
_Host.Open();
_Manager = new Manager();
_Manager.Start();
}
和_Manager.Start()调用具有以下定义的Agent.Start()(注意Execute
public void Start()
{
_Thread = new Thread(new ThreadStart(Execute));
_Thread.Start();
}
参数Execute
是一个如下的函数
public void Execute()
{
//mapping data stuff here
//I put a break point at some line of code in this function
//but it is not reached
}
我在执行功能代码中设置了一个断点,但即使我按F11进入,它也不会转到Execute
功能。
它现在以某种方式进入Execute函数,Execute Function代码如下:
try
{ System.Messaging.Message amsg = _RequestQueue.Receive();
/// other code
}
每次通过此行时,调试器都会丢失...它保持静止但没有任何其他操作,我不知道它现在在哪里......
非常感谢。任何想法都表示赞赏。
答案 0 :(得分:1)
几点想法......
除非Execute()函数在附加到它之前完成操作,否则您应该能够连接。
编辑:
从MSDN,Revive()函数接收MessageQueue引用的队列中可用的第一条消息。此调用是同步的,会阻止当前执行的线程,直到消息可用。
您确定消息队列至少有一条消息吗?否则线程将被阻止。如果对消息进行排队,则可以看到调试器变为活动状态。
确保您已正确配置队列。