Show / Hide Table of Contents

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.

Inheritance
object
AsyncLazy<T>
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.Threading
Assembly: SoCore.dll
Syntax
public class AsyncLazy<T>
Type Parameters
Name Description
T

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
Type Name Description
Func<CancellationToken, Task<T>> valueTask

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
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task<T>

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top