how check programmatically whether wpf app working or not right now?, app.previnstance in vb. please suggest me simple method, beginner.
here code,
protected override void onstartup(startupeventargs e) { base.onstartup(e); var runningprocessbyname = process.getprocessesbyname("tclcgfp"); if (runningprocessbyname.length == 0) { //process.start("tclcgfp.exe"); new traacsclcprocess(); } else { messagebox.show("application running.","tclcgfp",messageboxbutton.ok,messageboximage.information); } environment.exit(0); }
it showing application running :p
what people use named mutex object. use constructor overload tells if created find out if process has created 1 same name. example using mutex:
mutex mutex; try { mutex = mutex.openexisting("singleinstance"); if (mutex!= null) { console.writeline("error, 1 instance only"); application.exit(); } } catch (waithandlecannotbeopenedexception ex) { mutex = new mutex(true, "singleinstance"); }
you can read how determine if previous instance of application running?
Comments
Post a Comment