[MWB] Remove Thread.Suspend API usage, because it always results in PlatformNotSupportedException (#29746)

This commit is contained in:
Andrey Nekrasov
2023-11-13 15:56:18 +01:00
committed by GitHub
parent 25b92400fb
commit ba76bfe04e
2 changed files with 0 additions and 24 deletions

View File

@@ -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);

View File

@@ -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();