77namespace 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 {
0 commit comments