[Settings]Fix crash caused by dangling thread (#35603)

* Fix crash caused by dangling thread

* Fix process access to be able to WaitForSingleObject it
This commit is contained in:
Stefan Markovic 2024-10-27 21:51:11 +01:00 committed by GitHub
parent a0138cec5e
commit 83d3c85f3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -625,7 +625,7 @@ void close_settings_window()
if (g_settings_process_id != 0) if (g_settings_process_id != 0)
{ {
SetEvent(g_terminateSettingsEvent); SetEvent(g_terminateSettingsEvent);
wil::unique_handle proc{ OpenProcess(PROCESS_TERMINATE, false, g_settings_process_id) }; wil::unique_handle proc{ OpenProcess(PROCESS_ALL_ACCESS, false, g_settings_process_id) };
if (proc) if (proc)
{ {
WaitForSingleObject(proc.get(), 1500); WaitForSingleObject(proc.get(), 1500);

View File

@ -4,7 +4,7 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using Microsoft.UI.Dispatching; using Microsoft.UI.Dispatching;
namespace Microsoft.PowerToys.Settings.UI.Helpers namespace Microsoft.PowerToys.Settings.UI.Helpers
@ -14,7 +14,7 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
public static void WaitForEventLoop(string eventName, Action callback) public static void WaitForEventLoop(string eventName, Action callback)
{ {
var dispatcherQueue = DispatcherQueue.GetForCurrentThread(); var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
new Thread(() => new Task(() =>
{ {
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName); var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName);
while (true) while (true)