From ba76bfe04e12a95ecbfa6e7bf601b0526c3ebc56 Mon Sep 17 00:00:00 2001 From: Andrey Nekrasov Date: Mon, 13 Nov 2023 15:56:18 +0100 Subject: [PATCH] [MWB] Remove Thread.Suspend API usage, because it always results in PlatformNotSupportedException (#29746) --- .../App/Class/Common.Log.cs | 22 ------------------- .../MouseWithoutBorders/App/Class/Common.cs | 2 -- 2 files changed, 24 deletions(-) diff --git a/src/modules/MouseWithoutBorders/App/Class/Common.Log.cs b/src/modules/MouseWithoutBorders/App/Class/Common.Log.cs index c343bed3e5..02e65d3891 100644 --- a/src/modules/MouseWithoutBorders/App/Class/Common.Log.cs +++ b/src/modules/MouseWithoutBorders/App/Class/Common.Log.cs @@ -85,28 +85,6 @@ namespace MouseWithoutBorders return stack; } - internal static void SuspendAllThreadsBut(int threadId) - { - lock (ThreadsLock) - { -#pragma warning disable 618 // Temporary - threads.Where(t => t.IsAlive && t.ManagedThreadId != threadId).ToList().ForEach( - t => - { - try - { - t.Suspend(); - } - catch (Exception) - { - // This method is suspending every thread so that it can kill the process right after restarting. - // Makes no sense to crash on a thread suspension fail, since we're killing the process afterwards, anyway. - } - }); -#pragma warning restore 618 - } - } - internal void SetApartmentState(ApartmentState apartmentState) { thread.SetApartmentState(apartmentState); diff --git a/src/modules/MouseWithoutBorders/App/Class/Common.cs b/src/modules/MouseWithoutBorders/App/Class/Common.cs index 4731eb9cfe..2c58537302 100644 --- a/src/modules/MouseWithoutBorders/App/Class/Common.cs +++ b/src/modules/MouseWithoutBorders/App/Class/Common.cs @@ -349,8 +349,6 @@ namespace MouseWithoutBorders _ = Process.Start(Application.ExecutablePath, desktop); LogDebug($"Started on desktop {desktop}"); - Thread.SuspendAllThreadsBut(Thread.CurrentThread.ManagedThreadId); - Process.GetCurrentProcess().KillProcess(true); }, $"{actionName} watchdog").Start();