Jump to content
Sign in to follow this  
p.gabor

How do I make LabVIEW close a popup window?

Recommended Posts

Imagine the following situation: My LabVIEW application sometimes has to perform a task that takes about 30 seconds. I would like LabVIEW to display a popup window asking the user to wait, and to close the window automatically (without mandatory user intervention, such as clicking a mouse) once the task is complete. What is the most reasonable way of implementing such a feature?

As you can see, this is far from being a matter of life and death, but I would be grateful for any pointers. I believe LabVIEW allows for several different approaches :wacko: , but I have no time to explore them. Hence my question.

Share this post


Link to post
Share on other sites

QUOTE (p.gabor @ Oct 3 2008, 10:03 AM)

Imagine the following situation: My LabVIEW application sometimes has to perform a task that takes about 30 seconds. I would like LabVIEW to display a popup window asking the user to wait, and to close the window automatically (without mandatory user intervention, such as clicking a mouse) once the task is complete. What is the most reasonable way of implementing such a feature?

As you can see, this is far from being a matter of life and death, but I would be grateful for any pointers. I believe LabVIEW allows for several different approaches :wacko: , but I have no time to explore them. Hence my question.

You can make your task a VI and then set it as dialog (VI Poroperties, Windows Appearance, and click Dialog). Then you VI will be shown until execution ended.

Share this post


Link to post
Share on other sites

QUOTE (pdc @ Oct 3 2008, 04:10 PM)

You can make your task a VI and then set it as dialog (VI Poroperties, Windows Appearance, and click Dialog). Then you VI will be shown until execution ended.

Thanks! This is perfect!!! Why haven't I thought of it myself? :rolleyes:

It does work very well in my situation, and I AM very happy about the idea, but... am I to understand that there is no simple way of doing what I describe in my original question (making LabVIEW to open and subsequently close a popup window)? :blink:

Thanks again,

pg

Share this post


Link to post
Share on other sites

QUOTE (p.gabor @ Oct 3 2008, 10:03 AM)

Imagine the following situation: My LabVIEW application sometimes has to perform a task that takes about 30 seconds. I would like LabVIEW to display a popup window asking the user to wait, and to close the window automatically

Having the task as a Dialog VI is probably the easiest way of doing it, as pdc mentioned. When the task is done, the dialog will close and all's said and done.

There are other ways though. Maybe you want your task to be run outside of the UI thread, maybe it's asynchronous with respect to the rest of your code, or maybe there's the possibility of multiple tasks but you only want one dialog? In situations like that I usually use one of the synchronization objects (a dynamic event/occurrence/notifier/queue), the VI that spawns the worker task creates the event/whatever, and feeds it to both the dialog and the worker task. When the worker task is done, it signals the event, to which the dialog responds and closes. Just be careful not to create a race condition where it's possible for the worker thread to signal the sync object before the dialog blocks. Which object to use really depends on what you want to do, is a simple signal all you need or do you need to send data with the signal? Do you need to respond to multiple signals?

Share this post


Link to post
Share on other sites

QUOTE (Dave Graybeal @ Oct 3 2008, 04:27 PM)

Thanks a lot for this suggestion. It does look very nice. I may use it somewhere, although perhaps pdc's solution (VI Properties, Windows Appearance -> Dialog) is perfectly adequate for what I need.

pg

QUOTE (MJE @ Oct 3 2008, 04:41 PM)

Having the task as a Dialog VI is probably the easiest way of doing it, as pdc mentioned. When the task is done, the dialog will close and all's said and done.

There are other ways though. Maybe you want your task to be run outside of the UI thread, maybe it's asynchronous with respect to the rest of your code, or maybe there's the possibility of multiple tasks but you only want one dialog? In situations like that I usually use one of the synchronization objects (a dynamic event/occurrence/notifier/queue), the VI that spawns the worker task creates the event/whatever, and feeds it to both the dialog and the worker task. When the worker task is done, it signals the event, to which the dialog responds and closes. Just be careful not to create a race condition where it's possible for the worker thread to signal the sync object before the dialog blocks. Which object to use really depends on what you want to do, is a simple signal all you need or do you need to send data with the signal? Do you need to respond to multiple signals?

Thanks for the reply. In fact, the problem is quite elementary. There is no need to send any data with the signal, there no other tasks (the application is perfectly linear - apart from the popup window ;) ). For "serious stuff" I would not hesitate to use synchronization objects, but here... it seems like overkill. BTW, looking at the JKI pwd solution confirms your observation: he uses notifiers.

pg

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.