Skip to content

Commit e3408e9

Browse files
committed
Use CoWaitForMultipleObjects from CsWin32
1 parent b2f0284 commit e3408e9

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
@@ -229,3 +229,4 @@ QITIPF_FLAGS
229229
CreateEvent
230230
SetEvent
231231
ResetEvent
232+
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)