Hi TakuyaYamauchi-1944,
Connections, commands, and readers are not thread-safe. Therefore, if you intend to run this code in multiple threads, each thread needs to create its own connections, commands, and readers. And if your application is multi-threaded, you need to use it in each The COM object is instantiated in the thread.
The STA model is used for non-thread-safe COM objects. If the COM object can handle its own synchronization, you can use the MTA model, which allows multiple threads to interact with the object without marshalling calls.
Here is a thread to help you understand better.
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.