LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

No timer-callback

Hello,
 
I have a problem with my timer callback.
My timer should call every second the callback function, but when my program runs in a large function the
timer doesn´t call the callback function.
Is there a possibility to set a priority or the like?
 
Thanks
0 Kudos
Message 1 of 3
(3,401 Views)

Your function is blocking the events in your main thread so the Timer callback is not called and the Tick Event can not be processed.  If the actions performed by the timer can not collide with those performed by your other function (no access to the same resources) then you can execute them in a separate thread.  This is made easy by the use of an async timer.
Look for the example asyncdem in CVI (use the search function under Help==>Examples in the CVI menus).  It shows how to create another thread running from an async timer.  You can also search async timer in this forum, you will find a lot of threads that discuss it and provide tips on how to best use it in various designs.

Hope this helps, if it does not provide you with a solution or you have other questions about how to implement it, please post again.

Good Luck

0 Kudos
Message 2 of 3
(3,390 Views)

As mvr points out and the documentation for the standard CVI timer control states, there is no guarantee that you will get timer callbacks on time or even one for every timer interval. If your program is busy doing something else, the timer callbacks may never be generated.

Mutilthreading is really the way to go to both improve performance and ensure that timers are generating callbacks when expected. Fortunately, you do not have to dive directly into multithreading to get its benefit for timers. As mvr suggested, the best way to get around this problem is the asynchronous timer. This type of timer executes in its own thread and is very reliable. I have been using this type since it first became available and have been much happier with it. I have completely abandoned the use of standard CVI timer controls and will never go back to using them in new code. In fact, if I update an old program using a timer control, I replace it with the asynchronous timer.

 

 

 

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 3 of 3
(3,371 Views)