c# - Use mutext to detect and call started process -
how can use mutex find first process guid , call function in ? in web browser when try start second time open new window.
// appguid const string containing app guid using (mutex mutex = new mutex(false, "global\\" + appguid)) { if (!mutex.waitone(0, false)) { // code find , call first process , exit environment.exit(0); } else { app app = new app(); app.initializecomponent(); app.run(); } }
i think there lot of ways tackle "oh opened second instance, allow one, lets proxy request first instance" problem.
- you have host process listening on socket , when mutex detects been opened call listening socket. maybe use simple .net remoting, no real need go full blown wcf here or raw socket writing
- you have shared memory buffer , write using shared memory. require synchronization between 2 processes, can kinda messy
- you trigger file , have host process listening file events in known location. easiest, low-tech solution
that's 3 ideas, there more
but, if want process information why not process name?
Comments
Post a Comment