Out of Process COM Server - function calls and threads

When you have a COM server outside the process and you call a function from the client inside this server from Thread X inside the client, how does this function execute on the COM server?

In the thread that it is currently executing, or in the main thread?

+3
source share
3 answers

The normal rules for replenishing a COM apartment are observed. If the object was created by the client in the STA apartment, then your client stream must use a marshaled interface pointer or it receives RPC_E_WRONG_THREAD. The actual method call will be made on the server in its STA stream, it needs to pump the message loop for this. Execution is serialized; no lock is required.

If he lives in an MTA apartment, the method call will be executed on any RPC workflow. And you will need to take the usual precautions.

+2
source

Threads do not move from process to process.

Inside the COM server, the COM listens for incoming method calls and has a pool of threads (specific to this process) to serve the request.

+1
source

. , Stub.

. , -, .

, ? , , , -. - , . - , .

- RPC . - , . , , .

, , .

+1

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


All Articles