When you have an out of process COM Server and you call a function from a Client inside this server from Thread X inside the client, then how this function get executed in the COM Server?
In the thread its currently executing on, or on its main thread?
Normal COM apartment threading rules are observed. If the object was created by the client in an STA apartment then your client thread need to use a marshaled interface pointer or it gets RPC_E_WRONG_THREAD. The actual method call will execute on the server in its STA thread, it needs to pump a message loop for that to work. Execution is serialized, no locking should be needed.
If it lives in the MTA apartment then the method call will execute on an arbitrary RPC worker thread. And you'll need to take the usual threading precautions.
Threads do not jump from process to process.
Inside the COM Server, COM listens for incoming method calls and has a pool of threads (specific to this process) to serve the request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With