06-11-2015 02:55 AM - edited 06-11-2015 03:02 AM
There isn't a native function for handling structures: you can mimic the use of thread safe vars using locks: CmtNewLock, CmtGetLock, CmtReleaseLock, CmtTryToGetLock and CmtDiscardLock can be used to grant access to your variable from one thread only at a time. You must be sure to release every acquired lock when you no more need it. Look into utility library help for reference on those functions. See also this page of the Programmer Reference manual in CVI help.
Basically you must create a lock that you will use to protect your variable. You can either use CmtGetLock to acquire the lock: the function will be blocked until the lock is released from some other function that is curretly using it. If you do not want to be blocked, you can loop on CmtTryToGetLock thus gaining the additional possibility of having a timeout on the lock.
06-11-2015 02:57 AM
Did you also consider using a thread-safe queue with CmtNewTSQ?
There are also some examples for this, BuffNoDataLoss, DirectPtrAccess, Overflow. You find them in the sample folder utility/Threading/ThreadSafeQueue
06-11-2015 03:46 AM
Thx RobertoBozzolo and Wolfgang for your quick answers