LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Delay() and events ?

Does Delay() let draw events and system events happen in the meanwhile ?
--
Guillaume Dargaud
http://www.gdargaud.net/
"Mountains are Earth's undecaying monuments." - Nathaniel Hawthorne.
0 Kudos
Message 1 of 4
(3,303 Views)
Technically I am not sure what the answer is but I generally find that my applications keeps updating and allows me interaction when I call processsystemevents when entering a loop with delays that I can not control.
Jattie van der Linde
Engineering Manager, Software & Automation
TEL Magnetic Solutions Ltd
0 Kudos
Message 2 of 4
(3,302 Views)
Events are recognized but not processed while Delay() is running. To process system events and draw events while you're delaying, you can break the delay into smaller increments and call ProcessSystemEvents and ProcessDrawEvents at each increment. Depending on what events were generated, this may make your delay less accurate.
See the attached example which uses the function below.

void DelayWithEvents(int nDelay)
{
// #define are usually in a .h file or at the top of the .c file.
// it's included here for simplicity of the example.
#define DELAYSTEP 0.1 // incremental delay time in seconds
int i;
for (i=0; i*DELAYSTEP < nDelay; i++)
{
Delay(DELAYSTEP);
ProcessSystemEvents ();
ProcessDrawEvents ();
}
}
0 Kudos
Message 3 of 4
(3,303 Views)
Hi,

As Al_S says here, the events will be queued but not processed. You can also create an asynchronous delay in another thread. You spawn a new thread that waits and you get a notification that the delay has finished in a callback.

Here is a small example on how to spawn the thread and wait for the callback. Let me know if you have any further questions.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 4 of 4
(3,303 Views)