Skip to content

Commit

Permalink
Only allow one instance
Browse files Browse the repository at this point in the history
  • Loading branch information
TheXorog committed Jan 10, 2022
1 parent 1a40e57 commit cbf70f0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions BeatRecorder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ private async Task MainAsync(string[] args)

LogInfo("[BR] Loading settings..");

_ = Task.Run(async () =>
{
await Task.Delay(30000);

if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
{
LogError("Only one instance of this application is allowed");
Environment.Exit(0);
return;
}
});

if (File.Exists("Settings.json"))
{
try
Expand Down

0 comments on commit cbf70f0

Please sign in to comment.