From 5605256c75ff38475d154e917ecc3ae119569195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Sto=C5=A1i=C4=87?= Date: Fri, 27 Mar 2020 15:24:27 +0100 Subject: [PATCH] Prevent Window Walker from having multiple running instances (#1729) * Prevent Window Walker from having multiple running instances * Removed "Global" to allow multiple users to run Window Walker --- .../windowwalker/app/Window Walker/App.xaml.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/modules/windowwalker/app/Window Walker/App.xaml.cs b/src/modules/windowwalker/app/Window Walker/App.xaml.cs index 787aa56e74..94f9bcd3dc 100644 --- a/src/modules/windowwalker/app/Window Walker/App.xaml.cs +++ b/src/modules/windowwalker/app/Window Walker/App.xaml.cs @@ -2,6 +2,7 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. Code forked from Betsegaw Tadele's https://github.com/betsegaw/windowwalker/ +using System.Threading; using System.Windows; namespace WindowWalker @@ -11,5 +12,18 @@ namespace WindowWalker /// public partial class App : Application { + private Mutex _appMutex; + + public App() + { + // Check if there is already a running instance + _appMutex = new Mutex(false, Guid); + if (!_appMutex.WaitOne(0, false)) + { + Shutdown(); + } + } + + private static readonly string Guid = "5dedb2a2-690f-45db-9ef7-07605223a70a"; } }