Share via


AsyncLazy<T> Class

Definition

A thread-safe, lazily and asynchronously evaluated value factory.

generic <typename T>
public ref class AsyncLazy
template <typename T>
[Windows::Foundation::Metadata::WebHostHidden]
class AsyncLazy
public class AsyncLazy<T>
type AsyncLazy<'T> = class
Public Class AsyncLazy(Of T)

Type Parameters

T

The type of value generated by the value factory.

Inheritance
AsyncLazy<T>

Remarks

This class does not itself carry any resources needful of disposing. But the value factory may produce a value that needs to be disposed of, which is why this class carries a Microsoft.VisualStudio.Threading.AsyncLazy`1.DisposeValueAsync method but does not implement IDisposable.

Constructors

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

Initializes a new instance of the AsyncLazy<T> class.

Properties

IsValueCreated

Gets a value indicating whether the value factory has been invoked.

IsValueFactoryCompleted

Gets a value indicating whether the value factory has been invoked and has run to completion.

Methods

GetValue()

Gets the lazily computed value.

GetValue(CancellationToken)

Gets the lazily computed value.

GetValueAsync()

Gets the task that produces or has produced the value.

GetValueAsync(CancellationToken)

Gets the task that produces or has produced the value.

ToString()

Renders a string describing an uncreated value, or the string representation of the created value.

Applies to

Thread Safety

This type is thread-safe for all members.