LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does the user interface disables me from clicking another button while it's running a sweep?

Solved!
Go to solution

Hi,

 

When I run the user interface and click on a button that sweeps voltage for a period of time, I can not press any other button that is on my panel, lets say, Abort button that would stop the action.

So, when I'm taking data and I realize that I should stop it before it finishes the sweep, I can't and that is a really bad disadvantage.

 

how can I improve this problem?

 

Thanks

0 Kudos
Message 1 of 5
(3,984 Views)

There are better solutions, but a quick fix might be to simply include a call to ProcessSystemEvents(), somewhere in your time-consuming "sweeps voltage" loop. This will allow CVI to check for any button clicks.

 

For the future, you might want to investigate the use of Asynchronous Timers or MultiThreading, in order to perform intensive activities while retaining GUI responsiveness.

 

JR

0 Kudos
Message 2 of 5
(3,979 Views)

Hi,

 

Thanks, I added ProcessSystemEvents in the sweep loop, but still, when i click the Quit button, it doesn't quit right a way, it finishes the sweep and then quits the panel. the other buttons work though.

I need to be able to stop the sweep in the middle of its execution and this can be done either by quiting the panel( bad choice) or calling the abort funcion which when it's pressed, a global variable which is always at zero turns one, and the if statement breaks the function.

0 Kudos
Message 3 of 5
(3,973 Views)

Hi,

 

I could not quite understand your problem.

The ProcessSystemEvents function should do the trick in your case.

Does not your abort callback execute when you press the button?

If it does, why can't you use it to set a flag to finish your loop?

 

Can you put a breakpoint in your abort callback to be sure it is executed? 

Message Edited by ebalci on 09-14-2009 10:05 PM
S. Eren BALCI
IMESTEK
0 Kudos
Message 4 of 5
(3,961 Views)
Solution
Accepted by topic author m.s.taba

Hi m.s.taba,

it seems to me that your code executes the quit function but does not exits the loop you are in, so the program quits only at the end of the loop.

To prevent this you could:

  • use a variable global to both your long callback and the quit callback
  • call ProcessSytemEvents during the loop
  • the callback for the quit button sets the global variable
  • inside the loop, immediately after ProcessSystemEvents you must test the value of the global variable and if set you must exit from the loop
  • only after exiting the loop you can terminate your program


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 5 of 5
(3,953 Views)