mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-04 20:21:18 +08:00
[MWB]Fix thread suspend crash on process restart (#28609)
This commit is contained in:
parent
4ba1d83cf5
commit
c31211241d
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user