@@ -12,14 +12,15 @@ namespace Microsoft.Data.SqlClient.Utilities
1212{
1313 internal static class AsyncHelper
1414 {
15- internal static void ContinueTask ( Task task ,
16- TaskCompletionSource < object > completion ,
15+ internal static void ContinueTask (
16+ Task taskToContinue ,
17+ TaskCompletionSource < object > taskCompletionSource ,
1718 Action onSuccess ,
1819 Action < Exception > onFailure = null ,
1920 Action onCancellation = null ,
2021 Func < Exception , Exception > exceptionConverter = null )
2122 {
22- task . ContinueWith (
23+ taskToContinue . ContinueWith (
2324 tsk =>
2425 {
2526 if ( tsk . Exception != null )
@@ -35,7 +36,7 @@ internal static void ContinueTask(Task task,
3536 }
3637 finally
3738 {
38- completion . TrySetException ( exc ) ;
39+ taskCompletionSource . TrySetException ( exc ) ;
3940 }
4041 }
4142 else if ( tsk . IsCanceled )
@@ -46,7 +47,7 @@ internal static void ContinueTask(Task task,
4647 }
4748 finally
4849 {
49- completion . TrySetCanceled ( ) ;
50+ taskCompletionSource . TrySetCanceled ( ) ;
5051 }
5152 }
5253 else
@@ -58,7 +59,7 @@ internal static void ContinueTask(Task task,
5859 // @TODO: CER Exception Handling was removed here (see GH#3581)
5960 catch ( Exception e )
6061 {
61- completion . SetException ( e ) ;
62+ taskCompletionSource . SetException ( e ) ;
6263 }
6364 }
6465 } , TaskScheduler . Default
@@ -88,7 +89,6 @@ internal static void ContinueTaskWithState<TState>(
8889
8990 if ( task . Exception is not null )
9091 {
91- // @TODO: Exception converter?
9292 try
9393 {
9494 typedState2 . OnFailure ? . Invoke ( typedState2 . State , task . Exception ) ;
@@ -150,7 +150,6 @@ internal static void ContinueTaskWithState<TState1, TState2>(
150150
151151 if ( task . Exception is not null )
152152 {
153- // @TODO: Exception converter?
154153 try
155154 {
156155 typedState2 . OnFailure ? . Invoke ( typedState2 . State1 , typedState2 . State2 , task . Exception ) ;
@@ -258,13 +257,6 @@ internal static Task CreateContinuationTaskWithState<TState>(
258257 Action < TState , Exception > onFailure = null ,
259258 Action < TState > onCancellation = null )
260259 {
261- // Note: this code is almost identical to ContinueTaskWithState, but creates its own
262- // task completion source and completes it on success.
263- // Yes, we could just chain into the ContinueTaskWithState, but that requires wrapping
264- // more state in a tuple and confusing the heck out of people. So, duplicating code
265- // just makes things more clean. Besides, @TODO: We should get rid of these helpers and
266- // just use async/await natives.
267-
268260 if ( taskToContinue is null )
269261 {
270262 onSuccess ( state ) ;
0 commit comments