Skip to content

Commit 34c3efb

Browse files
committed
Use overload
1 parent 62b7d4c commit 34c3efb

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/Files.App/App.xaml.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,7 @@ private async void Window_Closed(object sender, WindowEventArgs args)
225225
var results = items.Select(x => x.ItemPath).ToList();
226226
System.IO.File.WriteAllLines(OutputPath, results);
227227

228-
HANDLE eventHandle = (HANDLE)PInvoke.CreateEvent(null, false, false, "FILEDIALOG").DangerousGetHandle();
229-
PInvoke.SetEvent(eventHandle);
230-
PInvoke.CloseHandle(eventHandle);
228+
FileDialogEvent();
231229
}
232230

233231
// Continue running the app on the background
@@ -305,6 +303,16 @@ private async void Window_Closed(object sender, WindowEventArgs args)
305303
FileOperationsHelpers.WaitForCompletion();
306304
}
307305

306+
private unsafe void FileDialogEvent()
307+
{
308+
fixed (char* fileDialog = "FILEDIALOG")
309+
{
310+
HANDLE eventHandle = PInvoke.CreateEvent(bManualReset: false, bInitialState: false, lpName: fileDialog);
311+
PInvoke.SetEvent(eventHandle);
312+
PInvoke.CloseHandle(eventHandle);
313+
}
314+
}
315+
308316
/// <summary>
309317
/// Gets invoked when the last opened flyout is closed.
310318
/// </summary>

src/Files.App/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ private static async void OnActivated(object? sender, AppActivationArguments arg
250250
/// <remarks>
251251
/// Redirects on another thread and uses a non-blocking wait method to wait for the redirection to complete.
252252
/// </remarks>
253-
public static void RedirectActivationTo(AppInstance keyInstance, AppActivationArguments args)
253+
public static unsafe void RedirectActivationTo(AppInstance keyInstance, AppActivationArguments args)
254254
{
255-
HANDLE eventHandle = (HANDLE)PInvoke.CreateEvent(null, true, false, null).DangerousGetHandle();
255+
HANDLE eventHandle = PInvoke.CreateEvent(bManualReset: true, bInitialState: false, lpName: null);
256256

257257
Task.Run(() =>
258258
{
@@ -273,9 +273,9 @@ public static void OpenShellCommandInExplorer(string shellCommand, int pid)
273273
Win32Helper.OpenFolderInExistingShellWindow(shellCommand);
274274
}
275275

276-
public static void OpenFileFromTile(string filePath)
276+
public static unsafe void OpenFileFromTile(string filePath)
277277
{
278-
HANDLE eventHandle = (HANDLE)PInvoke.CreateEvent(null, true, false, null).DangerousGetHandle();
278+
HANDLE eventHandle = PInvoke.CreateEvent(bManualReset: true, bInitialState: false, lpName: null);
279279

280280
Task.Run(() =>
281281
{

0 commit comments

Comments
 (0)