diff --git a/Defrag/App.xaml.cs b/Defrag/App.xaml.cs index 3614b83..12ce5f6 100644 --- a/Defrag/App.xaml.cs +++ b/Defrag/App.xaml.cs @@ -34,17 +34,14 @@ private async void OnSingleInstanceLaunched(object? sender, SingleInstanceLaunch } else { - // Get the current process - var currentProcess = Process.GetCurrentProcess(); - - // Start a new instance of the application - if (currentProcess.MainModule != null) + if (MainAppWindow != null) { - Process.Start(currentProcess.MainModule.FileName); + _ = ((MainWindow)MainAppWindow).BringToFront(); + } + else + { + await LaunchWork(); } - - // Terminate the current process - currentProcess?.Kill(); return; } }