OT: ClickOnce and Mutexes

OT: ClickOnce and Mutexes

Old forum URL: forums.lhotka.net/forums/t/271.aspx


ajj3085 posted on Monday, June 05, 2006

Hi all,

I tried my luck with this question in google groups, but no luck.  So although its off topic, I'd like to see if anyone here has encounted and resolved this.

I have this code:

            appSingleton = new Mutex( false, "MedSales_App" );

            if ( appSingleton.WaitOne( 0, false ) ) {
                 // Start my app
            }
            else {
                 // Show  message that app is already running
            }

Executed on startup, to prevent multiple instances from running.     Everything works fine locally, but when you launch the application after a ClickOnce installation, it doesn't work; the apps don't see the mutexes and allow startup.

Any ideas?

Andy

ajj3085 replied on Wednesday, June 07, 2006

Just wanted to bump this, in case the person with the solution hasn't seen it yet :-)

amselem replied on Friday, June 09, 2006

This code works fine for me, even with clickonce deployments:

Private _Mutex As System.Threading.Mutex

Private Function IsOtherInstanceRunning() As Boolean

   Dim FirstInstance As Boolean
 
 
   _Mutex = New Threading.Mutex(False, "MyApplication", FirstInstance)
  
   Return Not FirstInstance

End Function

Hope that helps,
Regards

ajj3085 replied on Monday, June 12, 2006

Hi amselem,

I tried checking the output boolean, but again this doesn't work for me with ClickOnce applications.  It works fine if I run the application locally, but if I run from the shortcut which is created by the ClickOnce installation, I can still start mutliple instances.

Andy

Copyright (c) Marimer LLC