判断是否为重新启动的代码
public partial class App : Application { private static Mutex AppMutex; protected override void OnStartup(StartupEventArgs e) { AppMutex = new Mutex(true, "ZrClient", out var createdNew); if (!createdNew) { var current = Process.GetCurrentProcess(); foreach (var process in Process.GetProcessesByName(current.ProcessName)) { if (process.Id != current.Id) { Win32Helper.SetForegroundWindow(process.MainWindowHandle); break; } } Shutdown(); } } }