LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Async timers

When I click a button, I create a timer like:

Timer_Id = NewAsyncTimer(0.1, -1, 0, TimerFunc, 0);

Now in TimerFunc, I use EventData1 param which is

if (Event == EVENT_TIMER_TICK) {
if ((double*)EventData1)
currentTime = *((double*)EventData1);


From help, eventData1 is a pointer to a double that represents the current
time in seconds and is relative to the start of the first timer event.

After some time, I destroy my timer with

DiscardAsyncTimer (Timer_id);

Problem is when I click the button again and create a new timer. The
EventData1 param keeps showing time from the very first timer that was
created, not when button was clicked. I am assuming the by creating a new
timer each time the button is clicked, EventData1 shall show me time from
that in
stant.


vishi
0 Kudos
Message 1 of 2
(2,827 Views)
Hello

The eventData1 is supposed to return the time from the very first call, not since the last time the timer was created. To achive the effect you require, you might need to keep track of it yourself with a global that you initialize and that keeps track of the number of callbacks that occured

I hope this helps

Thanks

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 2
(2,827 Views)