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
Post a Comment