| Constructor name |
| TaskCompletionSource() |
| TaskCompletionSource(CancellationToken token) Creates an instance of TaskCompletionSource with a CancellationToken so that the task can be canceled when CancellationToken is canceled. |
| Return type | Method name |
| void | setResult(TResult result) Returns the task instance. |
| boolean | trySetResult(TResult result) Completes the task with the specified result, unless the task has already been completed. If the task has already been completed, nothing will be done. |
| boolean | trySetException(Exception exception) Completes the task with the specified result, unless the task has already been completed. If the task has already been completed, nothing will be done. |
| Task< TResult > | getTask() Returns the task instance. |
| constructor |
public TaskCompletionSource() |
| constructor |
public TaskCompletionSource(CancellationToken token) |
| Creates an instance of TaskCompletionSource with a CancellationToken so that the task can be canceled when CancellationToken is canceled. |
Parameters
| Parameter name | Parameter desc |
| token | Transfers the notification that operations should be canceled. |
| Method |
public void setResult(TResult result) |
| Returns the task instance. |
Parameters
| Parameter name | Parameter desc |
| result | Transfers the notification that operations should be canceled. |
| Method |
public void trySetResult(TResult result) |
| Completes the task with the specified result, unless the task has already been completed. If the task has already been completed, nothing will be done. |
Parameters
| Parameter name | Parameter desc |
| result | Result of the task. |
| type | desc |
| boolean | true if the result is set successfully, false otherwise. |
| Method |
public boolean trySetException(Exception exception) |
| Completes the task with the specified exception, unless the task has already been completed. If the task has already been completed, nothing will be done. |
Parameters
| Parameter name | Parameter desc |
| exception | Exception object. |
| type | desc |
| boolean | true if the exception is set successfully, false otherwise. |
| Method |
public Task< TResult > getTask() |
| Returns the task instance. |
Return
| type | desc |
| Task< TResult > | Task instance. |