DotNext.Threading by Roman Sakno

<PackageReference Include="DotNext.Threading" Version="1.0.0" />

 AsyncLazy<T>

public class AsyncLazy<T>
Provides support for asynchronous lazy initialization.
public bool IsValueCreated { get; }

Gets a value that indicates whether a value has been computed.

public Task<T> Task { get; }

Gets task representing asynchronous computation of lazy value.

public Result<T>? Value { get; }

Gets value if it is already computed.

public AsyncLazy(T value)

Initializes a new instance of lazy value which is already computed.

public AsyncLazy(ValueFunc<Task<T>> valueFactory, bool resettable = false)

Initializes a new instance of lazy value.

public AsyncLazy(Func<Task<T>> valueFactory, bool resettable = false)

Initializes a new instance of lazy value.

public ConfiguredTaskAwaitable<T> ConfigureAwait(bool continueOnCapturedContext)

Configures an awaiter used to await asynchronous lazy initialization.

public TaskAwaiter<T> GetAwaiter()

Gets awaiter for the asynchronous operation responsible for computing value.

public bool Reset()

Removes already computed value from the current object.