AsyncHelperDoOperationAsyncTResult(FuncIAsyncContext, TResult, TaskConfig) Method

Executes the specified operation asynchronously.
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> DoOperationAsync<TResult>(
	Func<IAsyncContext, TResult> operation,
	TaskConfig? asyncConfig
)

Parameters

operation  FuncIAsyncContext, TResult
The operation to be executed.
asyncConfig  TaskConfig
The configuration for the asynchronous operation.

Type Parameters

TResult
The type of the result of the specified operation.

Return Value

TaskTResult
A TaskTResult that represents the asynchronous operation. Its result is the result of the operation if it has not been canceled, or the default value of TResult if the operation has been canceled and ThrowIfCanceled in asyncConfig was set to .

Exceptions

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

See Also