Skip to content

Commit bb7a0db

Browse files
authored
Code Quality: Removed extra code for async ops in Program class (#17100)
1 parent 26bbb9b commit bb7a0db

File tree

2 files changed

+2
-41
lines changed

2 files changed

+2
-41
lines changed

src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,6 @@ public static extern bool SetEvent(
6868
IntPtr hEvent
6969
);
7070

71-
[DllImport("ole32.dll")]
72-
public static extern uint CoWaitForMultipleObjects(
73-
uint dwFlags,
74-
uint dwMilliseconds,
75-
ulong nHandles,
76-
IntPtr[] pHandles,
77-
out uint dwIndex
78-
);
79-
8071
[DllImport("shell32.dll")]
8172
public static extern IntPtr SHBrowseForFolder(
8273
ref BROWSEINFO lpbi

src/Files.App/Program.cs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.Text;
1010
using Windows.ApplicationModel.Activation;
1111
using Windows.Storage;
12-
using static Files.App.Helpers.Win32PInvoke;
1312

1413
namespace Files.App
1514
{
@@ -21,9 +20,6 @@ namespace Files.App
2120
/// </remarks>
2221
internal sealed class Program
2322
{
24-
private const uint CWMO_DEFAULT = 0;
25-
private const uint INFINITE = 0xFFFFFFFF;
26-
2723
public static Semaphore? Pool { get; set; }
2824

2925
static Program()
@@ -250,20 +246,7 @@ private static async void OnActivated(object? sender, AppActivationArguments arg
250246
/// </remarks>
251247
public static void RedirectActivationTo(AppInstance keyInstance, AppActivationArguments args)
252248
{
253-
IntPtr eventHandle = CreateEvent(IntPtr.Zero, true, false, null);
254-
255-
Task.Run(() =>
256-
{
257-
keyInstance.RedirectActivationToAsync(args).AsTask().Wait();
258-
SetEvent(eventHandle);
259-
});
260-
261-
_ = CoWaitForMultipleObjects(
262-
CWMO_DEFAULT,
263-
INFINITE,
264-
1,
265-
[eventHandle],
266-
out uint handleIndex);
249+
keyInstance.RedirectActivationToAsync(args).AsTask().Wait();
267250
}
268251

269252
public static void OpenShellCommandInExplorer(string shellCommand, int pid)
@@ -273,20 +256,7 @@ public static void OpenShellCommandInExplorer(string shellCommand, int pid)
273256

274257
public static void OpenFileFromTile(string filePath)
275258
{
276-
IntPtr eventHandle = CreateEvent(IntPtr.Zero, true, false, null);
277-
278-
Task.Run(() =>
279-
{
280-
LaunchHelper.LaunchAppAsync(filePath, null, null).Wait();
281-
SetEvent(eventHandle);
282-
});
283-
284-
_ = CoWaitForMultipleObjects(
285-
CWMO_DEFAULT,
286-
INFINITE,
287-
1,
288-
[eventHandle],
289-
out uint handleIndex);
259+
LaunchHelper.LaunchAppAsync(filePath, null, null).Wait();
290260
}
291261
}
292262
}

0 commit comments

Comments
 (0)