Click or drag to resize

AsyncHelperNullGuardTResult Method (TaskTResult)

Insures that an awaited method always returns a Task.

Namespace:  Cauldron
Assembly:  Cauldron.Win32.WPF (in Cauldron.Win32.WPF.dll) Version: 3.2.0.1 (3.2.0.1)
Syntax
C#
public static Task<TResult> NullGuard<TResult>(
	Task<TResult> task
)

Parameters

task
Type: System.Threading.TasksTaskTResult
The awaitable task

Type Parameters

TResult
The type of the result produced by TaskTResult.

Return Value

Type: TaskTResult
An awaitable task
Exceptions
ExceptionCondition
NotSupportedExceptionTResult is a value type
Examples
var value = await AsyncHelper.NullGuard(instance.GetStuff()?.GetAllValuesAsync());
See Also