Class AsyncLazy<T>
Alternative to Lazy<T>. Simply wrapping our async tasks into a lazy value was
not satisfactory, because 1) if it threw an exception inside the task, it would be permanently
fixed to the lazy instance, and 2) it didn't allow us to pass a CancellationToken.
Assembly: SoCore.dll
Syntax
public class AsyncLazy<T>
Type Parameters
Constructors
AsyncLazy(Func<CancellationToken, Task<T>>)
Alternative to Lazy<T>. Simply wrapping our async tasks into a lazy value was
not satisfactory, because 1) if it threw an exception inside the task, it would be permanently
fixed to the lazy instance, and 2) it didn't allow us to pass a CancellationToken.
Declaration
public AsyncLazy(Func<CancellationToken, Task<T>> valueTask)
Parameters
AsyncLazy(Func<Task<T>>)
Alternative to Lazy<T>. Simply wrapping our async tasks into a lazy value was
not satisfactory, because 1) if it threw an exception inside the task, it would be permanently
fixed to the lazy instance, and 2) it didn't allow us to pass a CancellationToken.
Declaration
public AsyncLazy(Func<Task<T>> valueTask)
Parameters
Type |
Name |
Description |
Func<Task<T>> |
valueTask |
|
Methods
GetValueAsync(CancellationToken)
Alternative to Lazy<T>. Simply wrapping our async tasks into a lazy value was
not satisfactory, because 1) if it threw an exception inside the task, it would be permanently
fixed to the lazy instance, and 2) it didn't allow us to pass a CancellationToken.
Declaration
public Task<T> GetValueAsync(CancellationToken cancellationToken = default)
Parameters
Returns
Extension Methods