LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Soft Close LabVIEW application Running Under Different User

I like the service idea, I would improve on that to create a service that acts as a man in the middle between the instrument and your application.

 

  • The application will connect to the service to control the device
  • If a new application tries to connect with the service, it checks if it is free, if not it will disconnect connection with the existing application 
Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 11 of 17
(853 Views)

The other options discussed mostly seem like they could work, but just to throw something else out there, you could have your application register for the .NET event "SessionSwitch" and disconnect or exit when that occurs.

0 Kudos
Message 12 of 17
(845 Views)

Let me throw out a simpler solution- rework your program so it doesn't hold a handle to the hardware when idle.

 

You didn't say which hardware it was, but if it was something like a serial port, then don't open the port at the beginning of the application- open it at the beginning of your test, then close it at the end of your test. Then leaving the program running wouldn't lock any resources. Same with a DAQmx task.

 

Your program shouldn't need a hardware handle while it's running idle. Something as simple as a "watchdog" style timer could wait until the user hasn't interacted with the system for X minutes, then self-close the reference. Or use Kyle's suggestion for the .NET event, where it can disconnect its hardware resource.

 

When your user starts interacting with the program again, have it check for "Hardware connected?" and if not, reconnect it silently.

0 Kudos
Message 13 of 17
(838 Views)

@Kyle97330 wrote:

The other options discussed mostly seem like they could work, but just to throw something else out there, you could have your application register for the .NET event "SessionSwitch" and disconnect or exit when that occurs.


Do yo have an example?

System Events have no public constructors.

 

George Zou
0 Kudos
Message 14 of 17
(829 Views)

Example attached, backsaved just in case

Kyle97330_0-1677097043404.png

You don't need a "real" reference to pass in to a register event callback.  A constant works fine, so no need to make a constructor node if you know the class you need.

 

If you run this, then do a "switch user" to log out and back in as yourself real quick, it should fire 4 times, with a different reason enum each time.

Download All
Message 15 of 17
(799 Views)

You would need a valid reference normally.

But in this case, it's the system events.

 

 

George Zou
0 Kudos
Message 16 of 17
(770 Views)

@santo_13 wrote:

I like the service idea, I would improve on that to create a service that acts as a man in the middle between the instrument and your application.

 

  • The application will connect to the service to control the device
  • If a new application tries to connect with the service, it checks if it is free, if not it will disconnect connection with the existing application 

Would you have to start the service as an admin in this case?

 

 

------

And some completely noob questions:

And how does one connect to a service with labview? And how does one run labview as a service?

I couldn't find any "native" solutions online (only plugin and some horribly outdated info... also curses on NI for changing their domain and making most of the linked white papers in forum threads dead).

0 Kudos
Message 17 of 17
(750 Views)