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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -