p.gabor Posted October 4, 2008 Report Share Posted October 4, 2008 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 , but I have no time to explore them. Hence my question. Quote Link to comment
LAVA 1.0 Content Posted October 4, 2008 Report Share Posted October 4, 2008 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 , 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. Quote Link to comment
Dave Graybeal Posted October 4, 2008 Report Share Posted October 4, 2008 I would personally check out this handy tool available in the LAVA CR: http://forums.lavag.org/JKI-Please-Wait-Dialog-file21.html I've used this on multiple occasions and it is really nice to work with. Hope it helps, Dave Quote Link to comment
p.gabor Posted October 4, 2008 Author Report Share Posted October 4, 2008 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? 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)? Thanks again, pg Quote Link to comment
mje Posted October 4, 2008 Report Share Posted October 4, 2008 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? Quote Link to comment
p.gabor Posted October 4, 2008 Author Report Share Posted October 4, 2008 QUOTE (Dave Graybeal @ Oct 3 2008, 04:27 PM) I would personally check out this handy tool available in the LAVA CR:http://forums.lavag.org/JKI-Please-Wait-Dialog-file21.html I've used this on multiple occasions and it is really nice to work with. Hope it helps, Dave 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 Quote Link to comment
TobyD Posted October 4, 2008 Report Share Posted October 4, 2008 QUOTE (p.gabor @ Oct 3 2008, 07:03 AM) My LabVIEW application sometimes has to perform a task that takes about 30 seconds... If the task happens inside a For Loop you should check out the For Loop Progress Bar.vi from http://www.mooregoodideas.com/goodLabViewStuff.htm' rel='nofollow' target="_blank">Moore Good Ideas. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.