Skip to content

Commit 32406c6

Browse files
committed
Update
1 parent 5035fb7 commit 32406c6

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

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

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
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+
/// <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">Optional 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>
1420
public static Task Run(Action action, ILogger? logger = null)
1521
{
1622
var tcs = new TaskCompletionSource();
@@ -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,6 +49,13 @@ public static Task Run(Action action, ILogger? logger = null)
4449
return tcs.Task;
4550
}
4651

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">Optional 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>
4759
public static Task<T> Run<T>(Func<T> func, ILogger? logger = null)
4860
{
4961
var tcs = new TaskCompletionSource<T>();
@@ -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,6 +87,12 @@ public static Task<T> Run<T>(Func<T> func, ILogger? logger = null)
7687
return tcs.Task;
7788
}
7889

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">Optional 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>
7996
public static Task Run(Func<Task> func, ILogger? logger = null)
8097
{
8198
var tcs = new TaskCompletionSource();
@@ -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,6 +125,13 @@ public static Task Run(Func<Task> func, ILogger? logger = null)
109125
return tcs.Task;
110126
}
111127

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">Optional 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>
112135
public static Task<T?> Run<T>(Func<Task<T>> func, ILogger? logger = null)
113136
{
114137
var tcs = new TaskCompletionSource<T?>();
@@ -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
{

0 commit comments

Comments
 (0)