Using an obsolete COM component in a multithreaded C # environment

I have an outdated COM component, and my task is to write a web service that wraps COM and allows simultaneous non-blocking calls.

First of all, since the COM object itself has no state, I decided to use the [ThreadStatic] attribute so that each thread has its own instance of the COM object, to prevent the use of the lock {} operator and allow real parallel processing, but it seems that all calls are all still going on synchronously.

I wrote test code that runs a method from a COM component that is synchronous with the {} loop, and then added a second thread that does the same thing to another instance of the COM object, and I have not seen any changes, X calls always consume Y times, regardless of the number of threads. It looks like a static lock or something like that.

Despite this, separate processes can process each call simultaneously for a real one. What prevents individual species from behaving the same?

What can I do to enable real simultaneous calls to the COM component?

+3
source share
1 answer

COM , . ThreadingModel . "" ( ), COM , , , QI. , .

, , STA . , , , . .

+3

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


All Articles