LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

OPC Disconnect - Application Hangs

Hi !

 

I have an application connected to multiple OPC Items. During program run, everything works fine (I've got about 60 Items that read only, about 30 Items to write settings from time to time and about 10 items for cyclic output about 10 times per Sec.). But when shutting down the app, it often stays hanging when disconnecting. I suspect esp. the cyclic write items. Is there anything missing when disconnecting ?

 

Call for connect:
hr = DS_Open (strOpcUrl, Mode, DataSocketCallback, NULL, DSConst_WriteAutoUpdate);
hr = DS_Open (strOpcUrl, Mode, DataSocketCallback, NULL, DSConst_ReadAutoUpdate);

 

Call for output (e.g. of double value):
hr = DS_SetDataValue (intDSHandle, type, &dblValue, 0, 0);

 

Call for disconnect:
hr = DS_DiscardObjHandle (intDSHandle);

 

Is there anything missing for proper disconnect ?
Best regards,
Tom

0 Kudos
Message 1 of 3
(2,771 Views)

Hi Tomsaw,

 

did you already try the example in 

 

C:\Program Files\National Instruments\CVI2010\samples\datasocket\OpcClient\OpcClient.prj

 

and check if the disconnect hangs too?

 

Best Regards Lam

0 Kudos
Message 2 of 3
(2,739 Views)

Try calling CA_InitActiveXThreadStyleForCurrentThread (0, COINIT_APARTMENTTHREADED) before any other calls in your main function. This will make your program use a single thread for the OPC-DataSocket-ActiveX calls and may prevent the "hang".

0 Kudos
Message 3 of 3
(2,727 Views)