20 lines
372 B
C#
Raw Normal View History

2026-05-20 21:39:12 +08:00
using System.Threading;
namespace Neta.Tray;
public static class SingleInstance
{
private static Mutex? _mutex;
public static bool TryAcquire()
{
_mutex = new Mutex(true, @"Local\Neta.Tray", out var createdNew);
if (!createdNew)
{
_mutex.Dispose();
_mutex = null;
}
return createdNew;
}
}