mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
Use local mutexes (#10651)
* Update file config mutex code in KeyboardManager * Update runner instance mutex names and logic * Update Launcher mutex * Update a mutex in the Runner * Restored a mutex used in the installer * Update src/modules/launcher/PowerLauncher/App.xaml.cs Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
This commit is contained in:
@@ -29,7 +29,7 @@ namespace PowerLauncher
|
||||
{
|
||||
public static PublicAPIInstance API { get; private set; }
|
||||
|
||||
private const string Unique = "PowerLauncher_Unique_Application_Mutex";
|
||||
private const string Unique = "PowerToys_PowerToysRun_InstanceMutex";
|
||||
private static bool _disposed;
|
||||
private PowerToysRunSettings _settings;
|
||||
private MainViewModel _mainVM;
|
||||
|
||||
@@ -44,6 +44,11 @@ namespace PowerLauncher.Helper
|
||||
/// </summary>
|
||||
private const string ChannelNameSuffix = "SingeInstanceIPCChannel";
|
||||
|
||||
/// <summary>
|
||||
/// Prefix to the names of mutexes which ensures they are unique in a Windows session.
|
||||
/// </summary>
|
||||
private const string LocalMutexPrefix = @"Local\";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets application mutex.
|
||||
/// </summary>
|
||||
@@ -62,7 +67,8 @@ namespace PowerLauncher.Helper
|
||||
string channelName = string.Concat(applicationIdentifier, Delimiter, ChannelNameSuffix);
|
||||
|
||||
// Create mutex based on unique application Id to check if this is the first instance of the application.
|
||||
SingleInstanceMutex = new Mutex(true, applicationIdentifier, out bool firstInstance);
|
||||
string mutexName = string.Concat(LocalMutexPrefix, uniqueName);
|
||||
SingleInstanceMutex = new Mutex(true, mutexName, out bool firstInstance);
|
||||
if (firstInstance)
|
||||
{
|
||||
_ = CreateRemoteService(channelName);
|
||||
|
||||
Reference in New Issue
Block a user