LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to have function after a thread

I'm trying to have a function (A)) run in a new thread and once the function is completed, have another function (B) run in the main thread. To do this, I add the first function (A) to the thread pool and then call the second function(B). But for some reason, when the sequence is executed, the second function(B) gets executed before the first (A). How can I alter my program to get the functionality I want. I have included the function that demonstrates this. In the included file, I wish to calibrate using the ManualCalibrateThread function first, then when it is done executing, have the PDTESTPNL_STATUS text box show "Calibrate Done".
0 Kudos
Message 1 of 2
(2,931 Views)
Maybe I'm missing something, but I'm not sure why you would want to package your calibration function in a separate thread if all the main thread is doing is waiting for it to complete?

Anyway, what you need to do is have the function (A) in the new thread signal to the main thread that it is complete. The main thread can then wait to receive this signal before executing (B).

Depending on your inclination, the signal could be carried by something as lightweight as a global boolean variable (declared volatile), or a CVI thread-safe variable, or a windows message posted from the second thread to the main thread at the appropriate time.

HTH, HAND,
Martin.
--
Martin
Certified CVI Developer
0 Kudos
Message 2 of 2
(2,931 Views)