LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Deux UI Timers s'exécutent en parallèle

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 11 of 13
(2,091 Views)

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

0 Kudos
Message 12 of 13
(2,089 Views)

Thx and   for your quick answers  Smiley Happy

0 Kudos
Message 13 of 13
(2,078 Views)