Skip to content

Commit 9937cb3

Browse files
committed
Use CoWaitForMultipleObjects from CsWin32
1 parent 4264a2f commit 9937cb3

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Files.App.CsWin32/NativeMethods.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,4 @@ GetKeyboardLayout
228228
CreateEvent
229229
SetEvent
230230
ResetEvent
231+
CoWaitForMultipleObjects

src/Files.App/Program.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,22 @@ public static unsafe void RedirectActivationTo(AppInstance keyInstance, AppActiv
255255
{
256256
HANDLE hEventHandle = PInvoke.CreateEvent((SECURITY_ATTRIBUTES*)null, true, false, null);
257257

258+
HANDLE* pHandles = stackalloc HANDLE[1];
259+
pHandles[0] = hEventHandle;
260+
258261
Task.Run(() =>
259262
{
260263
keyInstance.RedirectActivationToAsync(args).AsTask().Wait();
261264
PInvoke.SetEvent(hEventHandle);
262265
});
263266

264-
_ = Win32PInvoke.CoWaitForMultipleObjects(
267+
uint dwIndex = 0u;
268+
PInvoke.CoWaitForMultipleObjects(
265269
CWMO_DEFAULT,
266270
INFINITE,
267-
1,
268-
[hEventHandle],
269-
out uint handleIndex);
271+
1u,
272+
pHandles,
273+
&dwIndex);
270274
}
271275

272276
public static void OpenShellCommandInExplorer(string shellCommand, int pid)

0 commit comments

Comments
 (0)