Click or drag to resize
TaskCompletionSourceExtensionsTrySetFromTaskTResult Method (TaskCompletionSourceTResult, Task, TResult)

Namespace: Rackspace.Threading
Assembly: Rackspace.Threading (in Rackspace.Threading.dll) Version: 2.1.0-beta1
Syntax
public static bool TrySetFromTask<TResult>(
	this TaskCompletionSource<TResult> taskCompletionSource,
	Task task,
	TResult result
)

Parameters

taskCompletionSource
Type: System.Threading.TasksTaskCompletionSourceTResult
The TaskCompletionSourceTResult instance.
task
Type: System.Threading.TasksTask
The result task whose completion results should be transferred.
result
Type: TResult
The result of the completion source when the specified task completed successfully.

Type Parameters

TResult
Specifies the result type of the TaskCompletionSourceTResult.

Return Value

Type: Boolean

if the operation was successful.

-or-

if the operation was unsuccessful or the object has already been disposed.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type TaskCompletionSourceTResult. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
ArgumentNullException

If taskCompletionSource is .

-or-

If task is .

Remarks

This method will return if the TaskTResult provided by taskCompletionSource is already in one of the three final states: RanToCompletion, Faulted, or Canceled. This method also returns if the underlying TaskTResult has already been disposed.

If task is in the RanToCompletion state, the specified result value is assigned to the TaskCompletionSourceTResult using the TrySetResult(TResult) method.

If task is in the Faulted state, the unwrapped exceptions are bound to the TaskCompletionSourceTResult using the TrySetException(IEnumerableException) method.

If task is in the Canceled state, the TaskCompletionSourceTResult is transitioned to the Canceled state using the TrySetCanceled method.

Version Information

.NET for Windows Store apps

Supported in: Windows 8

.NET Framework

Supported in: 4.5, 4.0, 3.5

Portable Class Library

Supported in: Portable Class Library (Legacy), Portable Class Library

Threading Library

Supported in: 2.1, 2.0, 1.1
See Also