From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

updating numerics from a loop

Solved!
Go to solution

I have a simple application that runs in a loop some number of times. Inside the loop data needs to be updated to numeric indicators. I can't get the indicators to change. The code that is calling the SetCtrlVal functions is inside a while loop. I'm calling ProccessDrawEvents having a vague memory that it is related.

0 Kudos
Message 1 of 10
(3,904 Views)

This is a fequent question Smiley Happy - searching the forum certainly would have shown the solution, e.g. here: the answer is to use ProcessDrawEvents() So if you do it should do the trick, if not, something probably is wrong: could you post the relevant section of your code?

0 Kudos
Message 2 of 10
(3,902 Views)

I actually did search and read that thread. I've always had success with ProcessDrawEvents but it isn't working in this case. I'll look at it some more.

0 Kudos
Message 3 of 10
(3,897 Views)

Okay I'm a moron. I'm reading some data from an instrument and the problem is in the looping code that's reading the ASCII string from the serial port. It was only getting it once so the numerics never changed.

0 Kudos
Message 4 of 10
(3,895 Views)

Working properly now.

0 Kudos
Message 5 of 10
(3,892 Views)

I'm relieved Smiley Happy

0 Kudos
Message 6 of 10
(3,890 Views)
Solution
Accepted by topic author tugofwar

Thanks! "ProcessDrawEvents()" solved my problem! Smiley Very Happy

0 Kudos
Message 7 of 10
(3,870 Views)

I'm seeing a similar issue. A callback function is running a long loop that is sending file data on a serial port. I'm updating a numeric slider (progress indicator) within the loop, and calling ProcessDrawEvents right after the control is updated. In my case, however, adding the call to ProcessDrawEvents did not solve the problem.

 

The issue goes away if I run the code from within the LabWindows IDE - everything works fine. However, if I simply launch the executable outside the IDE, the slider updates correctly for maybe 15 or 20 seconds, then the cursor changes to the busy indication, and the control does not update again until all of the data has been sent.

 

Any thoughts?

 

 

Message 8 of 10
(3,686 Views)

When I passed progress valuse to a slider I used ProcessSystemEvents() to update the GUI. I don't remember using ProcessDrawEvents()

0 Kudos
Message 9 of 10
(3,681 Views)

ProcessSystemEvents() does the trick for me, too, whereas ProcessDrawEvents() does not. I did discover that ProcessSystemEvents apparently has a pretty high execution cost, as it was slowing the loop down when I used it after each update to the slider. So I now call it on every 50th update. It still keeps the slider from stalling, but allows the loop to run much faster.

 

Thank you for the assistance!

 

0 Kudos
Message 10 of 10
(3,632 Views)