C #: only run an instance

xiaoxiao2021-03-06  16

///

/// The primary entry point of the application. /// [stathread] static void main () {// only one instance run // declares mutex. String info = "abcdefg"; <- The key is here, use it to identify if the program has run Mutex Mutex = New Mutex (false, info); // determine whether the mutex is used. Bool runexists =! Mutex.waitone (0, false); if (! Runexists) Application.run (New Form1 ()); Else MessageBox.show ("Application has started!");

}

转载请注明原文地址:https://www.9cbs.com/read-52296.html

New Post(0)