edimetia3d/OPC-Client-X64

Multi-threading issue in COPCClient.cpp

tomloya opened this issue · 1 comments

The old code that this was created from used CoInitalizeEx instead of CoInitialize. Also, there was protection around calling CoGetMalloc. I introduced a change to reinstate the original use of init() and stop() (though named differently) in a way that makes the client's usable in a multi-threaded situation. The init() function currently throws an error when being called from different threads, and also throws an error if you don't call it within each thread. The fix that I have put in (unfortunately over 2 commits) makes this work in a multi-threaded environment. I was using 20 threads to read/write values to/from the OPC server with my proposed change.

I tested your changes and it works fine.
Your commits have been merged to my repo.
Thanks for your contribution 👍