1

I have a WCF Windows Service, the OnStart function:

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();
}

and _Manager.Start() calls Agent.Start() which has following definition (pay attention the Execute

public void Start()
{
  _Thread = new Thread(new ThreadStart(Execute));
  _Thread.Start();
}

The parameter Execute is a function like following

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
}

I put a break point in Execute function code, but even if I press F11 for step in, it just does not go to the Execute Function.

It somehow goes into Execute function now, the Execute Function code is like:

try
  { System.Messaging.Message amsg = _RequestQueue.Receive();
    /// other code
  }

Everytime it passes this line, the debugger is lost...It stays still and doesnot have any other actions, I dont know where it is now...

Great thanks. Any ideas are appreciated.

4

1 回答 1

1

几个想法。。

  1. _Host.Open() 上是否有任何异常?
  2. 您确定线程已创建吗?我的意思是 Thread.Start() 被调用?

您应该能够附加,除非 Execute() 函数在附加之前完成它的操作。

编辑:

从 MSDN,Revive() 函数接收 MessageQueue 引用的队列中可用的第一条消息。此调用是同步的,并且会阻塞当前的执行线程,直到有消息可用。

您确定消息队列至少有一条消息吗?否则线程将被阻塞。如果将消息排队,则可以看到调试器变为活动状态。

确保您已正确配置队列。

于 2013-11-05T09:19:26.777 回答