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

Definition

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

public AsyncLazy (Func<System.Threading.Tasks.Task<T>> valueFactory, Microsoft.VisualStudio.Threading.JoinableTaskFactory joinableTaskFactory = default);
public AsyncLazy (Func<System.Threading.Tasks.Task<T>> valueFactory, Microsoft.VisualStudio.Threading.JoinableTaskFactory? joinableTaskFactory = default);
new Microsoft.VisualStudio.Threading.AsyncLazy<'T> : Func<System.Threading.Tasks.Task<'T>> * Microsoft.VisualStudio.Threading.JoinableTaskFactory -> Microsoft.VisualStudio.Threading.AsyncLazy<'T>
Public Sub New (valueFactory As Func(Of Task(Of T)), Optional joinableTaskFactory As JoinableTaskFactory = Nothing)

Parameters

valueFactory
Func<Task<T>>

The async function that produces the value. To be invoked at most once.

joinableTaskFactory
JoinableTaskFactory

The factory to use when invoking the value factory in GetValueAsync(CancellationToken) to avoid deadlocks when the main thread is required by the value factory.

Applies to