03-28-2011 02:48 AM - edited 03-28-2011 02:57 AM
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
04-21-2011 06:46 AM
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
04-21-2011 09:12 AM
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".