My console application uses third-party (non-Microsoft) application, which provides COM server functionality. I have implemented the IMessageFilter
interface in a way described here.
From the interface I expect that when the COM object does some task and cannot for example immediately quit on my request from another thread it would continuously call RetryRejectedCall()
and wait until the object is free.
However, I see that it does not work as this, but throws COMException
instead, where I try to close again and again. And after I receive OnQuit
event from COM object it calls RetryRejectedCall()
with value 2 (SERVERCALL_RETRYLATER
).
My log looks as follows:
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?
Questions:
- Is my expectation correct, or does it have another functionality?
- Should I implement
IMessageFilter
for the applications that work with COM objects at all? In my case it works as it was without the interface.