@@ -8,6 +8,7 @@ internal static class TaskAndFactoryExtensions
8
8
{
9
9
#region Task Extensions
10
10
11
+ // TODO: Not used, is this used in Deploy or something?
11
12
static void SetCompletionSource < TResult > ( TaskCompletionSource < TResult > completionSource , Task task )
12
13
{
13
14
if ( task . IsFaulted )
@@ -16,6 +17,7 @@ static void SetCompletionSource<TResult>(TaskCompletionSource<TResult> completio
16
17
completionSource . SetResult ( default ( TResult ) ) ;
17
18
}
18
19
20
+ // TODO: Not used, is this used in Deploy or something?
19
21
static void SetCompletionSource < TResult > ( TaskCompletionSource < TResult > completionSource , Task < TResult > task )
20
22
{
21
23
if ( task . IsFaulted )
@@ -24,17 +26,33 @@ static void SetCompletionSource<TResult>(TaskCompletionSource<TResult> completio
24
26
completionSource . SetResult ( task . Result ) ;
25
27
}
26
28
29
+ // TODO: Not used, is this used in Deploy or something?
27
30
public static Task ContinueWithTask ( this Task task , Func < Task , Task > continuation )
28
31
{
29
32
var completionSource = new TaskCompletionSource < object > ( ) ;
30
- task . ContinueWith ( atask => continuation ( atask ) . ContinueWith ( atask2 => SetCompletionSource ( completionSource , atask2 ) ) ) ;
33
+ task . ContinueWith ( atask => continuation ( atask ) . ContinueWith (
34
+ atask2 => SetCompletionSource ( completionSource , atask2 ) ,
35
+ // Must explicitly specify this, see https://blog.stephencleary.com/2013/10/continuewith-is-dangerous-too.html
36
+ TaskScheduler . Default ) ,
37
+ // Must explicitly specify this, see https://blog.stephencleary.com/2013/10/continuewith-is-dangerous-too.html
38
+ TaskScheduler . Default ) ;
31
39
return completionSource . Task ;
32
40
}
33
41
42
+ // TODO: Not used, is this used in Deploy or something?
34
43
public static Task ContinueWithTask ( this Task task , Func < Task , Task > continuation , CancellationToken token )
35
44
{
36
45
var completionSource = new TaskCompletionSource < object > ( ) ;
37
- task . ContinueWith ( atask => continuation ( atask ) . ContinueWith ( atask2 => SetCompletionSource ( completionSource , atask2 ) , token ) , token ) ;
46
+ task . ContinueWith ( atask => continuation ( atask ) . ContinueWith (
47
+ atask2 => SetCompletionSource ( completionSource , atask2 ) ,
48
+ token ,
49
+ TaskContinuationOptions . None ,
50
+ // Must explicitly specify this, see https://blog.stephencleary.com/2013/10/continuewith-is-dangerous-too.html
51
+ TaskScheduler . Default ) ,
52
+ token ,
53
+ TaskContinuationOptions . None ,
54
+ // Must explicitly specify this, see https://blog.stephencleary.com/2013/10/continuewith-is-dangerous-too.html
55
+ TaskScheduler . Default ) ;
38
56
return completionSource . Task ;
39
57
}
40
58
0 commit comments