Sign in to follow this  
Andreschrosa

Progress bar

Recommended Posts

I would like to have a progress bar show the progress of the network scan in my application, is it possible to update a progress bar from within a sequence?

I've tried and so far it updates to full when the sequence ends.

Share this post


Link to post
Share on other sites

Yes, just set the progress bar to display a global variable, then update that global from within the sequence. Make sure the range on the progress bar is appropriate. The thing is, if your sequence is running at full bore, doesn't have any delay()'s in it, and is at priority 2 or higher, then you are not letting the DAQFactory user interface update itself. This is why you see it update only at the end of the sequence. Try putting a small delay, even delay(0.01) inside your loop.

Share this post


Link to post
Share on other sites

I tested what you suggested, I noticed another thing: it works if I run the sequence opening it and typing F5, however I was running it from a button click using quick sequence... changed it to start/stop sequence and it worked!

Share this post


Link to post
Share on other sites

Yes, that is because when you call a sequence as a function, i.e.: sequencename() instead of using beginseq(sequencename) you are running the script in the thread of the calling script. The action of a button runs in the main thread of the application which handles the user interface. Since the thread is tied up doing your script it can't do anything else with the user interface.

You should never put script that takes a long time inside (or called from) the action of a screen control. You should always put it in a sequence and then start that sequence using beginseq() to run it in a background thread.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this