Table of Contents

Class AsyncLazy<T>

Namespace
MADE.Threading
Assembly
MADE.Threading.dll

Defines a provider for lazy asynchronous initialization of a value.

public class AsyncLazy<T>

Type Parameters

T

The type of object that is being lazily initialized.

Inheritance
AsyncLazy<T>
Inherited Members
Extension Methods

Constructors

AsyncLazy(Func<Task<T>>)

Initializes a new instance of the AsyncLazy<T> class with the specified asynchronous value factory.

public AsyncLazy(Func<Task<T>> valueFactory)

Parameters

valueFactory Func<Task<T>>

The asynchronous delegate that is invoked to produce the lazily initialized value when it is needed.

AsyncLazy(Func<Task<T>>, bool)

Initializes a new instance of the AsyncLazy<T> class with the specified asynchronous value factory and thread safety mode.

public AsyncLazy(Func<Task<T>> valueFactory, bool isThreadSafe)

Parameters

valueFactory Func<Task<T>>

The asynchronous delegate that is invoked to produce the lazily initialized value when it is needed.

isThreadSafe bool

A value indicating whether the AsyncLazy<T> instance should be usable concurrently by multiple threads.

Properties

IsValueCreated

Gets a value indicating whether a value has been created.

public bool IsValueCreated { get; }

Property Value

bool

Methods

GetAwaiter()

Gets the lazily initialized value as an awaitable task.

public TaskAwaiter<T> GetAwaiter()

Returns

TaskAwaiter<T>

An awaitable task that returns the lazily initialized value.

GetValueAsync()

Gets the lazily initialized value as a task.

public Task<T> GetValueAsync()

Returns

Task<T>

A task that returns the lazily initialized value.