Changeset 2666


Ignore:
Timestamp:
5/24/2012 7:41:48 AM (2 years ago)
Author:
lowjoel
Message:

Merged revision(s) 2661 from trunk/eraser: Handle the situation where creating a new mutex when starting the application would cause an UnauthorizedAccessException?. I can't figure out when this can happen since our mutex name contains the windows SID of the user launching it, but we'll have to live with it for now.

Location:
branches/eraser6/6.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/6.0

  • branches/eraser6/6.0/Eraser/Program.cs

    r2263 r2666  
    296296            this.CommandLine = commandLine; 
    297297 
    298             //Check if there already is another instance of the program. 
    299             globalMutex = new Mutex(true, instanceID, out isFirstInstance); 
     298            try 
     299            { 
     300                isFirstInstance = false; 
     301                globalMutex = new Mutex(true, instanceID, out isFirstInstance); 
     302            } 
     303            catch (UnauthorizedAccessException) 
     304            { 
     305                //If we get here, the mutex exists but we cannot modify it. That 
     306                //would imply that this is not the first instance. 
     307                //See http://msdn.microsoft.com/en-us/library/bwe34f1k.aspx 
     308                isFirstInstance = false; 
     309            } 
    300310        } 
    301311 
Note: See TracChangeset for help on using the changeset viewer.