LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I delay and still keep system running?

Solved!
Go to solution

Hello all,

 

I have two functions in the specified order:

DoTest1();

Delay(6.0);    // delay for 6 seconds.

DoTest2();

 

After doing DoTest1() function, my intent is to delay for 6 seconds before doing DoTest2() function. However, Delay(6.0) also stops test system from generating 1 second timer pulses to UUT and prevents UUT from working. I realized that when I replaced "Delay(6.0) with "MessagePopUp" function and I tell the operator to wait for 6.0 seconds, it works (or test passes).

My question is "Is there a function which would cause a delay for a specified amount of time before doing a specific task but still not hinder other activities from taking place?"

Your help would be appreciated.

Thank you.

 

Robert Mensah

 

0 Kudos
Message 1 of 6
(3,853 Views)
What you want to do is call ProcessSystemEvents() during your delay, as ProcessSystemEvents() allows for things like timers to fire.  You need to be careful though, as ProcessSystemEvents() will also allow the user to interact with the user interface, while the Delay() function now locks them out, so you may need to disable controls you don't want the user playing around with during the 6 seconds.  The easiest way is to just call ProcessSystemEvents() in a loop for six seconds, similar to this:

double starttime;

DoTest1();

starttime = Timer();
do
{
      ProcessSystemEvents();
}while((Timer() - starttime) < 6.0);//6.0s delay

DoTest2();


You may find it convienent to make a function out of the ProcessSystemEvents delay loop if you find you need it a lot.
Message 2 of 6
(3,833 Views)
You could also enable a 6 second timer upon completion of Test1.  In the timer callback, execute test2 and then disable the timer.
0 Kudos
Message 3 of 6
(3,823 Views)
Solution
Accepted by topic author Robert_Mensah

Hello Stanley,

 

Thank you very much for your immediate reply. Your code worked beatifully. Thanks again.

 

Robert Mensah

0 Kudos
Message 4 of 6
(3,812 Views)

I am writing multi thread programming. One thresd has to be excuted inspite of using "Delay(0.5);" function.  Will this Delay fucntion stop the other tread too?

0 Kudos
Message 5 of 6
(2,935 Views)

hello kumar

if you use delay your other task is not executing.

0 Kudos
Message 6 of 6
(2,830 Views)