Skip to content

Commit

Permalink
Fix single instance behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
IviriusMain committed Oct 9, 2024
1 parent 2e51ba2 commit ed79ab7
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions Defrag/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit ed79ab7

Please sign in to comment.