LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

holding down left click on a UIR object slow down timer events

Solved!
Go to solution

Hi everyone,

I have always had this problem, now i want to investigate it more deeply.

 

I've tryed with CVI2012 and CVI2020 and the behaviour is the same, I have a timer that run every 0.001 s, almost every cycle without delay, but when i keep the mouse clicked on an object the timer goes up to 0.1 s.

 

I've tryed to change the sleep policy but get no improvements, you can see this behaviour simulating a UIR in CVI2020 and looking in the events list or running the example "events".

 

attached a picture that show the difference with mouse clicked and not.

 

timer.png

Davide Vittorio G. - TLGB S.R.L.
Italian SW Developer
0 Kudos
Message 1 of 4
(623 Views)
Solution
Accepted by topic author holly7787

Yes, this is a known... problem? feature?... that depends on how UI timers are implemented in CVI.

The actual solution is to simply forget about those timers and move to async timers or to multithreading, especially if you want to keep with the millisecond resolution (which can actually be hard to maintain in the long time event with those alternatives).

 

The easiest solution is to move to async timers: you simply have to create the timer and pass the same callback of the UI timer to it. The only difference is that 'panel' parameter of the function callback is reserved in the async timer callback so you have to find an alternative in case you are actually using it in the timer callback.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(612 Views)

Is the same thought that I've had, but I want to avoid the AsyncTimer because I think of that as a multithread not managed, also NI reccomend to use thread pool instead.

 

I was hoping in some settings like SetSleepPolicy, or SetIdleEventRate, but this doesn't fix, I've already tryed it.

 

Multithread is probably the only way to manage this time critical part, but this will increase a lot the complexity of the software.

 

I'll give a try with the AsyncTimer and hope to don't get strange behaviour.

 

As usual thanks Roberto

Davide Vittorio G. - TLGB S.R.L.
Italian SW Developer
0 Kudos
Message 3 of 4
(598 Views)

Well, I have used both thread pools and async timers in my applications and never had relevant problems.

Async timers are implemented as a "pin-to-pin" replacement of UI timers: they share a very similar behavior and even the callback definition is the same. They are intended as an easy way to introduce multithreading in applications and are powerful enough to substitute UI timers without major problems. I'd give them a try before considering to move to a more complex multithreaded scenario.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 4
(590 Views)