Skip to content

Commit cbf70f0

Browse files
committed
Only allow one instance
1 parent 1a40e57 commit cbf70f0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

BeatRecorder/Program.cs

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ private async Task MainAsync(string[] args)
2828

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

31+
_ = Task.Run(async () =>
32+
{
33+
await Task.Delay(30000);
34+
35+
if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
36+
{
37+
LogError("Only one instance of this application is allowed");
38+
Environment.Exit(0);
39+
return;
40+
}
41+
});
42+
3143
if (File.Exists("Settings.json"))
3244
{
3345
try

0 commit comments

Comments
 (0)