Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

CNiDataSocket - multi-threading

Hello everybody,
 
I'm student and I develop in MFC project with Measurement Studio for VC++ 6.0.
I use the CNiDataSockets to connect on the OPCs of a industrial system (Festo).
 
When I use it without threads, my program runs correctly.
But when I use multi-threading, I have a RunTime Exception.

By using debug mode, I saw that the execption was caused by the function CNiDataSocket.Update ();
I have tested two type of threads : AfxThread MFC and Posix Threads with the library pthread for win32.
 
Is there something special to use the CNiDataSocket in multi-threading environnement?
 
Thank you for your answer.

O.C
0 Kudos
Message 1 of 2
(4,960 Views)

Did you try catching the exception and displaying the message? If so, what is the message?

The CNiDataSocket class libraries use a COM server underneath. This means that you need to call CoInitialize in any thread that uses it. If you haven't done that, you will get an exception. The exception message should inform you if this is the problem.

0 Kudos
Message 2 of 2
(4,935 Views)