AsyncHelperFromResultTResult(TResult, TResult, TaskConfig) Method

Returns a task that represents an already completed operation with a result.
See the Examples section of the AsyncHelper class for details.

Definition

Namespace: KGySoft.Threading
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.2.0
C#
public static Task<TResult> FromResult<TResult>(
	TResult result,
	TResult canceledResult,
	TaskConfig? asyncConfig
)

Parameters

result  TResult
The result to be returned by the returned task if the operation has not been canceled.
canceledResult  TResult
The result to be returned by the returned task if the operation has been canceled and ThrowIfCanceled of asyncConfig returns .
asyncConfig  TaskConfig
The configuration for the asynchronous operation.

Type Parameters

TResult
The type of the result.

Return Value

TaskTResult
A TaskTResult that represents the completed operation. Its result is result if the operation has not been canceled, or canceledResult if the operation has been canceled and ThrowIfCanceled in asyncConfig was set to .

Exceptions

TaskCanceledExceptionThe operation has been canceled and ThrowIfCanceled in asyncConfig was . This exception is thrown when the result is awaited.

See Also