c# - Error: Mutex to check, if the application is already running -


hey guys i've got following problem: declared mutex check, if application running. if file need in project missing, there error message , method, closes application before initializecomponent(). everytime file missing, error due following line:

w.show(); 

here is, i've got far:

startup="application_startup">  public void application_startup(object sender, startupeventargs e)     {         bool absicherung;         mutex mutex = new mutex(true, this.gettype().guid.tostring(), out absicherung);          if (absicherung)         {             window w = new mainwindow();             w.closed += (sender2, args) => mutex.close(); ;             w.show();         }         else         {             messagebox.show("die anwendung läuft bereits. eine mehrfache ausführung dieser ist nicht vorgesehen.", "hinweis: anwendung läuft bereits", messageboxbutton.ok, messageboximage.information);             mutex.close();             application.current.shutdown();         }     } 

how can fix problem? please me? in advance.

edit: problem fixed. solution: closing application this.close() wrong way - works using application.current.shutdown(); --> ~closed.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -