Provides the ability to create an incomplete Task and later complete it by either
calling setResult(TResult) or setException(Exception).
Public Constructor Summary
Public Method Summary
| Task<TResult> |
getTask()
Returns the Task.
|
| void | |
| void |
setResult(TResult result)
Completes the Task with the specified result.
|
| boolean |
trySetException(Exception e)
Completes the Task with the specified exception, unless the Task has already completed.
|
| boolean |
trySetResult(TResult result)
Completes the Task with the specified result, unless the Task has already completed.
|
Inherited Method Summary
Public Constructors
public TaskCompletionSource ()
Public Methods
public void setException (Exception e)
Completes the Task with the specified exception.
Throws
| IllegalStateException | if the Task is already complete |
|---|
public void setResult (TResult result)
Completes the Task with the specified result.
Throws
| IllegalStateException | if the Task is already complete |
|---|
public boolean trySetException (Exception e)
Completes the Task with the specified exception, unless the Task has already completed. If the Task has already completed, the call does nothing.
Returns
trueif the exception was set successfully,falseotherwise
public boolean trySetResult (TResult result)
Completes the Task with the specified result, unless the Task has already completed. If the Task has already completed, the call does nothing.
Returns
trueif the result was set successfully,falseotherwise
