IMessageFilter用于控制台应用程序

时间:2018-09-26 08:17:06

标签: c# com ole imessagefilter

我的控制台应用程序使用提供COM服务器功能的第三方(非Microsoft)应用程序。我已经以here描述的方式实现了IMessageFilter接口。

我希望从接口中,当COM对象执行某些任务并且例如无法立即从另一个线程退出我的请求时,它将连续调用RetryRejectedCall()并等待该对象释放。

但是,我发现它不能这样工作,而是抛出COMException,在此尝试一次又一次关闭。在我收到来自COM对象的OnQuit事件后,它调用值为{2(RetryRejectedCall())的SERVERCALL_RETRYLATER

我的日志如下:

Info:   COM - opening project 'MyProject'...
Info:   Console_CancelKeyPress event fired.      // I pressed ctrl+c
Info:   COM - quitting... (attempt 1)            // quit() called from another thread
Error:  COM - failed to close, it might be busy.
Info:   COM - quitting... (attempt 2)
Info:   COM - project 'MyProject' opened.
Info:   COM - quit successfully                  // quit only after open operation complete
Debug:  RetryRejectedCall: dwRejectType=2
Debug:  Test run thread is being aborted
Info:   COM - quit successfully              // why quit again?

问题:

  1. 我的期望是正确的,还是还有其他功能?
  2. 我应该为可以运行的应用程序实现IMessageFilter吗? 与COM对象?就我而言,它就像没有 界面。

0 个答案:

没有答案