| LoggerSwallowAsyncTResult Method (FuncTaskTResult, TResult) |
Runs the provided async function and returns its result. If the task does not run to completion, an exception is logged at Error level.
The exception is not propagated outside of this method; a fallback value is returned instead.
Namespace:
NLog
Assembly:
NLog (in NLog.dll) Version: 5.3.4+73d83d3161d31288ca5c554cc50d27b6bed5f28b
Syntax public Task<TResult> SwallowAsync<TResult>(
Func<Task<TResult>> asyncFunc,
TResult fallback
)
Public Function SwallowAsync(Of TResult) (
asyncFunc As Func(Of Task(Of TResult)),
fallback As TResult
) As Task(Of TResult)
Dim instance As Logger
Dim asyncFunc As Func(Of Task(Of TResult))
Dim fallback As TResult
Dim returnValue As Task(Of TResult)
returnValue = instance.SwallowAsync(asyncFunc,
fallback)
abstract SwallowAsync :
asyncFunc : Func<Task<'TResult>> *
fallback : 'TResult -> Task<'TResult>
override SwallowAsync :
asyncFunc : Func<Task<'TResult>> *
fallback : 'TResult -> Task<'TResult>
Parameters
- asyncFunc
- Type: SystemFuncTaskTResult
Async function to run. - fallback
- Type: TResult
Fallback value to return if the task does not end in the RanToCompletion state.
Type Parameters
- TResult
- Return type of the provided function.
Return Value
Type:
TaskTResultA task that represents the completion of the supplied task. If the supplied task ends in the
RanToCompletion state, the result of the new task will be the result of the supplied task; otherwise, the result of the new task will be the fallback value.
Implements
ISuppress.SwallowAsync``1(FuncTaskUMP, UMP)See Also