LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple copies of LV program running concurrently

Hi

I would like to be able to run several copies of a LV program, built as an EXE file in App Builder, at the same time. My program is a TCP/IP client which connects to various servers for datalogging purposes, and I would like to be able to have several windows open at the same time, each connected to a different server. When I try to start the program when the program is already running nothing happens. Is there a way to configure LV to allow multiple programs?

Best Regards
Bård
0 Kudos
Message 1 of 10
(7,564 Views)
Put the line
allowmultipleinstances=True

in the ini file of the application.


LabVIEW, C'est LabVIEW

Message 2 of 10
(7,546 Views)

@BBend wrote:
Is there a way to configure LV to allow multiple programs?

There is the relatively recently revealed, unsupported, use-at-your-own risk INI file setting allowmultipleinstances=True which has been discussed in the Lava forums. And an example of potential problems using it was discussed here.
=====================================================
Fading out. " ... J. Arthur Rank on gong."
Message 3 of 10
(7,544 Views)
Thanks for the advice. I've put the allowmultipleinstances=True line in the ini-file but unfortunately it doesn't seem to work on my application. When I try to start the program the second time the already running program pops up.I can run the program twice if I run one instance from LV and one from compiled program, but that's not a practical option. Are the ini-file options casesensitive and is it possible that the line should be different (I've tried to change some characters to uppercase without success)? Is there a way to monitor that your ini-files options has been accepted/rejected?

BBend
0 Kudos
Message 4 of 10
(7,522 Views)
Forgot to mention I run LV 7.1

BBend
0 Kudos
Message 5 of 10
(7,522 Views)
I successfully used the following method in LV7.0. It is a bit more complex than you might need since I wanted to communicate between the different instances of the application that I launched, so I made sure they were all launched into the same run-time engine.
  1. Add the following lines to the INI file of your application

    server.tcp.access="+localhost"
    hideRootWindow=true
    server.tcp.port=3301
    socketsetreuseaddr=false
    server.tcp.enabled=true
    allowmultipleinstances=true

  2. Add two more files to your application - a launcher and a splash screen. The launcher is responsible for launching the splash screen into a specific run-time engine. The splash screen will launch your actual application using the VI server normally. See the attached image for how to launch into a specific run-time engine. Note that you can set the TCP port to any valid value. My application happens to use 3301.

  3. Make your application into a VI template. On Windows, just change the file extension from .vi to .vit. Now every time the splash screen launches it, a new instance is created.
As mentioned before, there are lots of ways to shoot yourself in the foot when you do something like this. You have to make your code multi-instance safe. Do not use globals (use dynamically created LV2 globals instead). Make sure code which needs to be reentrant is.

My apologies for not posting code. The only example I have is embedded in a fairly complex application. If I have time, I will try to extricate it and post it.

One last thing to watch out for. The LabVIEW run-time engine continuously monitors whether or not a front panel is open. If all front panels are closed, the engine exits. When you transition from your launcher to your splash screen to your application, make sure one opens before the previous one closes. You can do this using either queues or notifiers.
Message 6 of 10
(7,498 Views)
Hi DFgray

Thanks for your suggestion to solving my problem. As you mention it is a rather complex solution and it involves some LV techniques I am not familiar with yet. Since this multiinstance functionality is not a requirement from my customers, but rather something I would like to test out if its possible to do it in an easy way, I'm not comfortable about adding code which might mess up a already working program.

If this becomes a requirement I might try your solution (if I can figure it out) but first it is worthwile to investigate if your complex solution can be applied to my application, or if the added complexity is because our applications are fundamentaly different.

You say

"I wanted to communicate between the different instances of the application that I launched, so I made sure they were all launched into the same run-time engine."

which I interpret as you launch the same application several times (on the same PC) and they are able to talk with each other.

In my case my programs are connected to different servers and therefore has no connection to each other, so its a bit like launching Notepad several times.

It seems to me (but I have not studied it very thorougly), the added lines in the ini-file and the added code is needed for your application but not neccesarily for mine.

It is strange that the allowmultipleinstances=true

isn't sufficient since it appear it has worked for other people. I have compiled a simple example file, which doesn't use sockets, and tried to run several copies without success.

About the use of global variables my program uses it and it might not work properly even if I solve this problem ("solving a problem creating another one" dilemma). I'm not sure if its going to be a problem though, because I can run program twice if one instance is run from the LV development program and the other is the compiled one, changing globals on one doesn't affect the other one. Maybe this is because they use different RTE, I dont know?

Anyway thanks for all the suggestions. It is nice to see somebody putting a lot of effort into trying to help "strangers" (or I guess we're all part of the big Labview family, right 🙂 I will play around with it for a while, and if I come up with something I post it on the Forum.

Best Regards
BBend
Message 7 of 10
(7,454 Views)
"It is nice to see somebody putting a lot of effort into trying to help "strangers" (or I guess we're all part of the big Labview family, right 🙂 I will play around with it for a while, and if I come up with something I post it on the Forum.
"

Correct!

Just try to answer as many Q's as you receive A's and the Exchange will run forever and get better as we go.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 10
(7,442 Views)
Hi BBend,

I think the reason you may be having troubles is because the ini file must be formatted in the following way. If your executable file is MyApp.exe and thus your ini file is MyApp.ini, your ini file should look like this:

[MyApp]
allowmultipleinstances = TRUE


My guess is that you're leaving out the "[MyApp]" part. Give this a shot and see if it works!

Hope this helps,
Travis H.
LabVIEW R&D
National Instruments
Message 9 of 10
(7,361 Views)
Brilliant!

You are a genious Travis! (Or maybe I'm an idiot 🙂 That's exactly the solution to the problem I've been struggeling with for a while. Now I can run as many copies of the program as I like. I was warned that using globals could be a problem, but the globals used in the program seems to be "local" to each copy of the program, so changing globals in one instance doesn't affect the other instances.

Thanks a lot!

Best Regards
BBend
0 Kudos
Message 10 of 10
(7,324 Views)