Skip to content

Commit

Permalink
[Settings]Fix crash caused by dangling thread (microsoft#35603)
Browse files Browse the repository at this point in the history
* Fix crash caused by dangling thread

* Fix process access to be able to WaitForSingleObject it
  • Loading branch information
stefansjfw authored Oct 27, 2024
1 parent a0138ce commit 83d3c85
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/runner/settings_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ void close_settings_window()
if (g_settings_process_id != 0)
{
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)
{
WaitForSingleObject(proc.get(), 1500);
Expand Down
4 changes: 2 additions & 2 deletions src/settings-ui/Settings.UI/Helpers/NativeEventWaiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System;
using System.Threading;

using System.Threading.Tasks;
using Microsoft.UI.Dispatching;

namespace Microsoft.PowerToys.Settings.UI.Helpers
Expand All @@ -14,7 +14,7 @@ public static class NativeEventWaiter
public static void WaitForEventLoop(string eventName, Action callback)
{
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
new Thread(() =>
new Task(() =>
{
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName);
while (true)
Expand Down

0 comments on commit 83d3c85

Please sign in to comment.