public < TContinuationResult > Task < TContinuationResult > continueWithTask ( final Continuation < TResult , Task < TContinuationResult > > continuation , final Executor executor , final CancellationToken ct ) { boolean completed ; final bolts . TaskCompletionSource < TContinuationResult > tcs = new bolts . TaskCompletionSource <> ( ) ; synchronized ( lock ) { completed = this . isCompleted ( ) ; if ( ! completed ) { this . continuations . add ( new Continuation < TResult , Void > ( ) { @ Override public Void then ( Task < TResult > task ) { completeAfterTask ( tcs , continuation , task , executor , ct ) ; return null ; } } ) ; } } if ( completed ) { completeAfterTask ( tcs , continuation , this , executor , ct ) ; } return tcs . getTask ( ) ; }
Adds an Task - based continuation to this task that will be scheduled using the executor returning a new task that completes after the task returned by the continuation has completed .