07-08-2010 05:21 AM
Dear All,
I would like to run two threads simultaneously and I would like to
know what I should do to synchronize them. What I really need to do is
to have one thread execute a command when the other thread has reached
the end of its cycle.
Thanks you very much for your help,
David.
07-09-2010 02:51 AM
CVI offers a set of commands for communications between threads.
Since the discussion title refers to plotting data, I suppose your aim is to pass test results from one thread to the UI thread for it to plot them on the screen / save on disk. If so, you can use a thread safe queue between the threads installing a callback in the UI thread to handle data in the queue. By appropriately setting trigger mechanism you may be sure that the UI thread callback is called only when the correct amount of data is passed to the queue.
Another option is to call PostDeferredCall at the end of test cycle inside the test thread: the deferred function is executed in the main thread (that normally is the one that handles the user interface). The reverse mechanism is to use PostDeferredCallToThread or PostDeferredCallToThreadAndWait in the main thread to execute a function within the specified different thread.