modified single instance feature

This commit is contained in:
2026-08-09 20:21:30 +05:00
parent 0c2f0bd618
commit 1fc9765a3d
+20 -2
View File
@@ -20,13 +20,31 @@ public sealed class SingleInstanceGate : IDisposable
private const string ActivationEventName = "CursorLang.ActivationRequest";
private readonly Dispatcher _dispatcher = Dispatcher.CurrentDispatcher;
private readonly string _mutexName;
private readonly string _activationEventName;
private Mutex? _mutex;
private EventWaitHandle? _activationRequest;
private RegisteredWaitHandle? _activationWait;
private bool _isOwner;
/// <summary>Другой запуск просит показать окно.</summary>
public SingleInstanceGate()
: this(string.Empty)
{
}
/// <summary>
/// Adds a distinguishing part to the kernel object names. Needed by the tests:
/// otherwise they would share the single-instance slot with the running
/// application and get in its way.
/// </summary>
internal SingleInstanceGate(string nameSuffix)
{
_mutexName = MutexName + nameSuffix;
_activationEventName = ActivationEventName + nameSuffix;
}
/// <summary>Another launch asks for the window to be shown.</summary>
public event EventHandler? ActivationRequested;
/// <summary>
@@ -35,7 +53,7 @@ public sealed class SingleInstanceGate : IDisposable
/// </summary>
public bool TryAcquire()
{
_mutex = new Mutex(initiallyOwned: false, MutexName);
_mutex = new Mutex(initiallyOwned: false, _mutexName);
try
{