Metux 实现单例进程
WPF 单例
public abstract class SingletonApplication : Application { private Mutex _singleTonApp = null; protected SingletonApplication(string appName) { _singleTonApp = new Mutex(true, appName, out var createdNew); if (createdNew) { // ReSharper disable once VirtualMemberCallInConstructor CreatedNewApp(); } else { // ReSharper disable once VirtualMemberCallInConstructor UpdateApp(); } } /// <summary> /// 首次运行app /// </summary> protected abstract void CreatedNewApp(); /// <summary> /// 已经有app在运行 /// </summary> protected abstract void UpdateApp(); }