[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 коммит произвёл GitHub
Родитель 25b92400fb
Коммит ba76bfe04e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 0 добавлений и 24 удалений

Просмотреть файл

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

Просмотреть файл

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