mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 12:46:47 +02:00
[MWB]Fix thread suspend crash on process restart (#28609)
This commit is contained in:
@@ -90,7 +90,19 @@ namespace MouseWithoutBorders
|
|||||||
lock (ThreadsLock)
|
lock (ThreadsLock)
|
||||||
{
|
{
|
||||||
#pragma warning disable 618 // Temporary
|
#pragma warning disable 618 // Temporary
|
||||||
threads.Where(t => t.IsAlive && t.ManagedThreadId != threadId).ToList().ForEach(t => t.Suspend());
|
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
|
#pragma warning restore 618
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user