Skip to content

Commit 60c5dfc

Browse files
committed
Added the "null" to the logger param
1 parent 5035fb7 commit 60c5dfc

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

src/Files.App.Storage/Windows/Helpers/WindowsStorableHelpers.Icon.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static partial class WindowsStorableHelpers
2929
{
3030
HRESULT hr = storable.TryGetThumbnail(size, options, out var thumbnailData).ThrowIfFailedOnDebug();
3131
return thumbnailData;
32-
});
32+
}, null);
3333
}
3434

3535
/// <summary>

src/Files.App.Storage/Windows/Managers/STATask.cs

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@
77
namespace Files.App.Storage
88
{
99
/// <summary>
10-
/// Represents a synchronous/asynchronous operation on STA.
10+
/// Represents a work scheduled to execute on a STA thread.
1111
/// </summary>
1212
public partial class STATask
1313
{
14-
public static Task Run(Action action, ILogger? logger = null)
14+
/// <summary>
15+
/// Schedules the specified work to execute in a new background thread initialized with STA state.
16+
/// </summary>
17+
/// <param name="action">The work to execute in the STA thread.</param>
18+
/// <param name="logger">A logger to capture any exception that occurs during execution.</param>
19+
/// <returns>A <see cref="Task"/> that represents the work scheduled to execute in the STA thread.</returns>
20+
public static Task Run(Action action, ILogger? logger)
1521
{
1622
var tcs = new TaskCompletionSource();
1723

@@ -29,7 +35,6 @@ public static Task Run(Action action, ILogger? logger = null)
2935
{
3036
tcs.SetResult();
3137
logger?.LogWarning(ex, "An exception was occurred during the execution within STA.");
32-
tcs.SetException(ex);
3338
}
3439
finally
3540
{
@@ -44,7 +49,14 @@ public static Task Run(Action action, ILogger? logger = null)
4449
return tcs.Task;
4550
}
4651

47-
public static Task<T> Run<T>(Func<T> func, ILogger? logger = null)
52+
/// <summary>
53+
/// Schedules the specified work to execute in a new background thread initialized with STA state.
54+
/// </summary>
55+
/// <typeparam name="T">The type of the result returned by the function.</typeparam>
56+
/// <param name="func">The work to execute in the STA thread.</param>
57+
/// <param name="logger">A logger to capture any exception that occurs during execution.</param>
58+
/// <returns>A <see cref="Task"/> that represents the work scheduled to execute in the STA thread.</returns>
59+
public static Task<T> Run<T>(Func<T> func, ILogger? logger)
4860
{
4961
var tcs = new TaskCompletionSource<T>();
5062

@@ -61,7 +73,6 @@ public static Task<T> Run<T>(Func<T> func, ILogger? logger = null)
6173
{
6274
tcs.SetResult(default!);
6375
logger?.LogWarning(ex, "An exception was occurred during the execution within STA.");
64-
tcs.SetException(ex);
6576
}
6677
finally
6778
{
@@ -76,7 +87,13 @@ public static Task<T> Run<T>(Func<T> func, ILogger? logger = null)
7687
return tcs.Task;
7788
}
7889

79-
public static Task Run(Func<Task> func, ILogger? logger = null)
90+
/// <summary>
91+
/// Schedules the specified work to execute in a new background thread initialized with STA state.
92+
/// </summary>
93+
/// <param name="func">The work to execute in the STA thread.</param>
94+
/// <param name="logger">A logger to capture any exception that occurs during execution.</param>
95+
/// <returns>A <see cref="Task"/> that represents the work scheduled to execute in the STA thread.</returns>
96+
public static Task Run(Func<Task> func, ILogger? logger)
8097
{
8198
var tcs = new TaskCompletionSource();
8299

@@ -94,7 +111,6 @@ public static Task Run(Func<Task> func, ILogger? logger = null)
94111
{
95112
tcs.SetResult();
96113
logger?.LogWarning(ex, "An exception was occurred during the execution within STA.");
97-
tcs.SetException(ex);
98114
}
99115
finally
100116
{
@@ -109,7 +125,14 @@ public static Task Run(Func<Task> func, ILogger? logger = null)
109125
return tcs.Task;
110126
}
111127

112-
public static Task<T?> Run<T>(Func<Task<T>> func, ILogger? logger = null)
128+
/// <summary>
129+
/// Schedules the specified work to execute in a new background thread initialized with STA state.
130+
/// </summary>
131+
/// <typeparam name="T">The type of the result returned by the function.</typeparam>
132+
/// <param name="func">The work to execute in the STA thread.</param>
133+
/// <param name="logger">A logger to capture any exception that occurs during execution.</param>
134+
/// <returns>A <see cref="Task"/> that represents the work scheduled to execute in the STA thread.</returns>
135+
public static Task<T?> Run<T>(Func<Task<T>> func, ILogger? logger)
113136
{
114137
var tcs = new TaskCompletionSource<T?>();
115138

@@ -126,7 +149,6 @@ public static Task Run(Func<Task> func, ILogger? logger = null)
126149
{
127150
tcs.SetResult(default);
128151
logger?.LogWarning(ex, "An exception was occurred during the execution within STA.");
129-
tcs.SetException(ex);
130152
}
131153
finally
132154
{

src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public override async Task ExecutePinToSidebarCommand(WidgetCardItem? item)
216216
// NOTE: "pintohome" is an undocumented verb, which calls an undocumented COM class, windows.storage.dll!CPinToFrequentExecute : public IExecuteCommand, ...
217217
return windowsFile.TryInvokeContextMenuVerb("pintohome");
218218
}
219-
});
219+
}, App.Logger);
220220

221221
if (hr.ThrowIfFailedOnDebug().Failed)
222222
return;
@@ -253,7 +253,7 @@ public override async Task ExecuteUnpinFromSidebarCommand(WidgetCardItem? item)
253253
// NOTE: "remove" is for some shell folders where the "unpinfromhome" may not work
254254
return windowsFile.TryInvokeContextMenuVerbs(["unpinfromhome", "remove"], true);
255255
}
256-
});
256+
}, App.Logger);
257257

258258
if (hr.ThrowIfFailedOnDebug().Failed)
259259
return;

0 commit comments

Comments
 (0)