LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

OpenExisting mutex creates new mutex

I have a .dll that is called by another program that creates a named mutex and releases it as a signal to LabView that it can perform a motion task.

Using the .net class 'mutex', method 'OpenExisting', and passing it the name of the mutex creates a new mutex with the same name.  I can create a mutex in LabView and then it gives me a reference that I can use to 'WaitOne', etc. and it works fine.  Any idea how to create a reference to a named mutex other than 'OpenExisting'?

Thanks,

Sean

0 Kudos
Message 1 of 4
(2,845 Views)

Hi Sean,

 

I am a little confused on what you are trying to do would you mind posting your vi here so I take a look?

Joe Daily
National Instruments
Applications Engineer

may the G be with you ....
0 Kudos
Message 2 of 4
(2,827 Views)

 


@shalloras wrote:

I have a .dll that is called by another program that creates a named mutex and releases it as a signal to LabView that it can perform a motion task.

Using the .net class 'mutex', method 'OpenExisting', and passing it the name of the mutex creates a new mutex with the same name.  I can create a mutex in LabView and then it gives me a reference that I can use to 'WaitOne', etc. and it works fine.  Any idea how to create a reference to a named mutex other than 'OpenExisting'?

Thanks,

Sean


 

Unless this .Net mutex is a wrapper around a Windows Critical Section only, it is likely that the scope of this mutex is process specific. This means that you can not optain a reference to the mutex from another process than the one who created it. This is actually the same with LabVIEW Semaphores (something similar to a mutex) which do have names but are only visible inside the same LabVIEW context (executable, project).

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 4
(2,823 Views)

What I have done is created a quick and dirty test rig where I can control the .dll, this would normally be done by the vendor program.  That is done by the top loop, what it does is either CreateMutexA() or ReleaseMutex().  The idea is that the .dll needs to signal the LV code that it is initialized and waiting for the OK to start a measurement (time resolved photoluminescence).  We are using a mutex as a simple way to implement a shared memory space.

The bottom loop then looks for a named mutex, returns a reference (see code below) and then uses WaitForSingleObject() to signal that the stage is in place and a measurement can now happen.  I can create the mutex from the .dll and see it from LV (i.e. 'existing?').  But when I try to signal using WaitForSingleObject(), it appears that I am not using the correct handle (see second pic).  I am assuming that the reference is not being cast correctly as a handle.

 

17341i4830348ADB100FF4

 

 

17345iB80BFE9C1ACDFE8E

Thanks a lot for the reply!

Sean

 

0 Kudos
Message 4 of 4
(2,812 Views)