11-16-2023 10:11 AM
In LabWindows 2017, we have a program that uses background async timers to poll some hardware. We used to use UI timers, but if you grabbed the window to move/resize it, those timers halt, and the hardware would timeout and shut down. Async timers solved that issue.
Now, there is one MessagePopup() that will cause the boards to stop being polled and time out. It is in a function, but we use MessagePopup() in many other places (callbacks) and they do not cause the polling to stop.
Anyone know the rule to this? Thanks for any tips.
11-16-2023 10:46 AM
Hello,
Popups don't cause async timers to pause. They don't even pause normal UIR timers. So there's something else going on in your code. Async timers are in a different threads, so even if you call while(1); or pause(); they won't stop being called.
As far as I know the only way to block async timers is with SuspendAsyncTimerCallbacks() or with some real low level stuff like interruption masking...
Or it's being called but your code is somehow ignoring it...
11-16-2023 10:48 AM
Interesting and useful. Yeah, we never turn off any timers down except when the program shuts down. Time to do some digging...
11-16-2023 11:02 AM
Or possibly you do some thread manipulation, like blocking other threads...
11-16-2023 11:55 AM - edited 11-16-2023 11:57 AM
Once I knew Popup did not halt anything, I did some stack call tracing and found the code ultimately was called from a timer callback. PostDeferred Call to the rescue once more!
PostDeferredCall ((DeferredCallbackPtr)MyFunction, NULL);
This allows the call to run after the timer code is done, from the main UI thread.
Solved. Thanks!
11-17-2023 02:13 AM
MessagePopup is a synchronous function: it means that code execution stops until the popup is dismissed.
As an alternative, you can use PostDeferredCall to call a function that is executed in the main thread to display messages: this does not interfere with timer execution.