How to trigger a release from a COM server

I am writing a Com server, and I wrote code that detects a situation where the COM client was unexpectedly closed, in which case I have to close the COM server inside the COM server code.

How can i do this?

UPD: I have situations where the COM server hanged or, rather, I can’t connect to the COM server from the COM client, but the application containing the COM server is alive, so I think the COM server can detect that all old COM clients were disconnected / closed / worked, and the application will restart as new clients are not connected.

I write the following code in a COM client in a separate thread

while(not we are closing)
{
   unknown->QueryInterface(IComServer, &server);

   if (server)
     return;
}

so that the COM client can wait until the server is really ready to work

UPD2: just tested: after 12 minutes my COM server was closed

+2
3

COM , , . , .

+4

, , . , , , . COM- , IUnknown:: Release(), . COM . , . , , .

- , . , , , WaitForMultipleHandles(). , , , , COM, , .

+3

COM proc , , . - COM . , , , . , , , , COM , .

0
source

Source: https://habr.com/ru/post/1761079/


All Articles