LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to put LabVIEW to sleep when it is deactivated?

I would like my LabVIEW executables to stop running when the user makes any other program become the active program and start running again when the user reactivates it. In VB this would be done with code attached to the deactivate and activate events. Is there any way to do this in LabVIEW?
0 Kudos
Message 1 of 5
(3,020 Views)
If you'd like to make such a control of your application, I think you'll have to run one loop anyway. So, I'd suggest using Windows Message Queue Library from:
http://zone.ni.com/devzone/devzoneweb.nsf/opendoc?openagent=2212A1CF726BE56C862567AC00583B8C
This will allow to monitor Windows events and react to desired events of activating/deactivating another applications they'll send to Windows in this small "daemon"-like loop. Can't explain to you the all small details, just giving to you an idea. This loop I'd call vi-server (as it hopefully should be :)). In this sample you'll find DLL source code to may be modify it a little.
Saying react to event I mean using vi/application referense and control, say boolean STOP button of your LabVIEW application and RUN
VI method of desired vi. In this case application will remain in memory and will be ready to stop/run upon request.

Hope that this should work.
Sergey
0 Kudos
Message 2 of 5
(3,020 Views)
Hi there,

There is a VI server command available called Is Foremost.

Calling up a property node (Virtual Instrument class) and then Properties /
Front Panel Window/ Is foremost will give a boolean variable based on
whether or not the labview program is foremost or not. Coupling this to a
routine in your code to enter a passive mode can then be implemented. How
you do this is of course dependent on what the software does......

Shane O`Neill


deserio@florida schrieb in Nachricht
<50650000000800000013160000-983677784000@quiq.com>...
>I would like my LabVIEW executables to stop running when the user
>makes any other program become the active program and start running
>again when the user reactivates it. In VB this would be done with
>code attached to the deactivate
and activate events. Is there any way
>to do this in LabVIEW?
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 3 of 5
(3,020 Views)
Thanks. Nearly perfect solution to the problem. Add one additional check to the main control loop to see if the VI is "foremost" (which seems to translate to active) and if not, run a while loop with a one second wait that doesn't exit until it is foremost. This makes a big difference in CPU usage and dramatically improves the response of other programs, while at the same time letting the labview program hog the CPU when it is active.
0 Kudos
Message 4 of 5
(3,020 Views)
Thanks. Nearly perfect solution to the problem. Add one additional check to the main control loop to see if the VI is "foremost" (which seems to translate to active) and if not, run a while loop with a one second wait that doesn't exit until it is foremost. This makes a big difference in CPU usage and dramatically improves the response of other programs, while at the same time letting the labview program hog the CPU when it is active.
0 Kudos
Message 5 of 5
(3,020 Views)