LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple instances of executable

I have built an Executable version of my program in LabVIEW. I call it through command line from another program (e.g : "C:\program files\app\app.exe")..
I was under the assumption that only one instance will always run no matter how many times you run it.


But sometimes (let us say 1/4) it runs two instances of the same application. This will have adverse effect on my application. so i tried to detect the previous by making calls to kernel32.dll and creating a named mutex. So if the named mutex already exists, i exit.

Well when i run the exe for the first time it starts the application. when i start the second instance, i see it for a second in the task manager and it disappears. when i start it for the third time, i get a memory
access violation dialog box from window.

"The instruction at "0x30308650" referenced memory at "0x00ec004". The memroy could not be written"

Every subsequent instance shows the same problem. if i remove my Mutex sutff and not do any internal detection, then sometimes it allows 2 instances of the same exe to run!!

Does anybody know a way around this?

Thanks,
anand.
0 Kudos
Message 1 of 11
(5,197 Views)
Hi,

You could make the command line call wait until finished. If the rest of the
calling application must continue, make a VI that can be called dynamically.
Now LV can test if the dynamic VI is still running, and if so, it can decide
not to call the VI again. Data in and out of the called executable can be
passed through a global buffer (or a normal one (not recommended)).

Regards,

Wiebe.

"Anand S R" wrote in message
news:50650000000800000044BB0000-1073519706000@exchange.ni.com...
> I have built an Executable version of my program in LabVIEW. I call it
> through command line from another program (e.g : "C:\program
> files\app\app.exe")..
> I was under the assumption that only one instance will always run no
> matter how many times you run it.
>
>

> But sometimes (let us say 1/4) it runs two instances of the same
> application. This will have adverse effect on my application. so i
> tried to detect the previous by making calls to kernel32.dll and
> creating a named mutex. So if the named mutex already exists, i exit.
>
> Well when i run the exe for the first time it starts the application.
> when i start the second instance, i see it for a second in the task
> manager and it disappears. when i start it for the third time, i get a
> memory access violation dialog box from window.
>
> "The instruction at "0x30308650" referenced memory at "0x00ec004". The
> memroy could not be written"
>
> Every subsequent instance shows the same problem. if i remove my Mutex
> sutff and not do any internal detection, then sometimes it allows 2
> instances of the same exe to run!!
>
> Does anybody know a way around this?
>
> Thanks,
> anand.
0 Kudos
Message 2 of 11
(5,198 Views)
The reason it is made a seperate executable is because it should have a seperate process address space and it should not impact my original application if there were to be any failures.

The main application has several dynamic vi's running (there are 62 threads in the main application already when it is running). So i dont think of re designing this architecture.

My doubts are regarding the NI LabVIEW exe. does it allow two instances of an executable? if it doesn't, how does it detect the second instance? Why does it sometimes let a second instance of the exe to run? After i deployed my application of a few machines i noticed that on most machines except 2, it my application detects the previous instances and exits gracefully
. but on two stations, it gets a memory access violation!! i cant figure out why. it doesnt get very far executing any labview code... it throws the execption just as it starts executing the code.

Anand
0 Kudos
Message 3 of 11
(5,198 Views)
I'm investigating the use of Rendezvous to accomplish a similar task..

I managed to get a crude, but working method, by wiring the System Exec.vi in parallel (with a delay between the two)... However, it doesn't seem to work well when running it within TestStand...

I will attempt something with the Rendezvous... I'll let you know how it went..

JLV
Message 4 of 11
(5,198 Views)
Hi,

Calling the exe from a dynamic VI would not need to change the architercture
at all. If one VI is used to call the executable, this VI can be replaced by
one VI that calls it dynamically.

Normally (it can be changed) LabVIEW can run only one instance at the same
time, so this most likelly will apply to an executable as well. I'll see if
I can reproduce the behaviour.

Regards,

Wiebe.


"Anand S R" wrote in message
news:506500000005000000EE510100-1073519706000@exchange.ni.com...
> The reason it is made a seperate executable is because it should have
> a seperate process address space and it should not impact my original
> application if there were to be any failures.
>
> The main application has several dynamic vi'
s running
> (there are 62 threads in the main application already when it
is
> running). So i dont think of re designing this architecture.
>
> My doubts are regarding the NI LabVIEW exe. does it allow
> two instances of an executable? if it doesn't, how does it
detect the
> second instance? Why does it sometimes let a second instance
of the
> exe to run? After i deployed my application of a few machines
i
> noticed that on most machines except 2, it my application
detects the
> previous instances and exits gracefully. but on two stations,
it gets
> a memory access violation!! i cant figure out why. it doesnt
get very
> far executing any labview code... it throws the execption just
as it
> starts executing the code.
>
> Anand
Message 5 of 11
(5,198 Views)
Hope you read your posts...

here is how I got it to work:

Open the vi which contains the first System Exec.vi.

(In LV) Under File menu, select "VI Properties".

Select category: Execution

In Preferred Execution System, select Other 1.

Let me know if it worked for you..

JLV
Message 6 of 11
(5,198 Views)
Check this link:

http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=50650000000800000012BC0000&USEARCHCONTEXT_CATEGORY_0=_49_%24_6_&USEARCHCONTEXT_CATEGORY_S=0&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0
Message 7 of 11
(5,198 Views)
Named Mutex can be used to detect previous instances of an exe. i am still not clear why labview allows 2 instances of an exe to run. but i have an sample vi that uses mutex to detect/create named mutex.
0 Kudos
Message 8 of 11
(5,199 Views)
I know this thread is rather old but still...

I have the same problem. Sometimes it is possible to start a new instance of the same app, sometimes not. For my application it is vital that only one instance is running.
I tried to understand your SetNamedMutex-vi with no luck.
Can I use it to find already running apps?
Here is what I have tried: I started "myapp.exe". The I run "SetNamedMutex.vi" with "myapp.exe" in the name-field. But no matter if myapp.exe is running or not, SetNamedMutex always returns 0 (Existing=false)
Could someone help me here?

LV7.0 Win2000
-DB
0 Kudos
Message 9 of 11
(5,036 Views)
Hi DB,
 
If I understand the suggestion correctly you should be able to include code similar to the follow to prevent an application from running multiple times.
 
 
Scott Y
NI

Message Edited by Scott Y on 07-14-2005 09:26 PM

0 Kudos
Message 10 of 11
(5,008 Views)