DevToys logo DevToys
  • Home
  • Blog
  • Documentation
  • Download
Search Results for

    Show / Hide Table of Contents

    Class AsyncLazy<T>

    Represents an asynchronous lazy initialization.

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

    The type of the value being lazily initialized.

    Constructors

    AsyncLazy(Func<Task<T>>)

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

    Declaration
    public AsyncLazy(Func<Task<T>> valueFactory)
    Parameters
    Type Name Description
    Func<Task<T>> valueFactory

    The delegate that represents the asynchronous value factory.

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

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

    Declaration
    public AsyncLazy(Func<Task<T>> valueFactory, bool isThreadSafe)
    Parameters
    Type Name Description
    Func<Task<T>> valueFactory

    The delegate that represents the asynchronous value factory.

    bool isThreadSafe

    A boolean value indicating whether the lazy initialization is thread-safe.

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

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

    Declaration
    public AsyncLazy(Func<Task<T>> valueFactory, LazyThreadSafetyMode mode)
    Parameters
    Type Name Description
    Func<Task<T>> valueFactory

    The delegate that represents the asynchronous value factory.

    LazyThreadSafetyMode mode

    The thread safety mode for the lazy initialization.

    AsyncLazy(Func<T>)

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

    Declaration
    public AsyncLazy(Func<T> valueFactory)
    Parameters
    Type Name Description
    Func<T> valueFactory

    The delegate that represents the value factory.

    AsyncLazy(Func<T>, bool)

    Creates a new instance of the AsyncLazy<T> class with the specified value factory and thread safety option.

    Declaration
    public AsyncLazy(Func<T> valueFactory, bool isThreadSafe)
    Parameters
    Type Name Description
    Func<T> valueFactory

    The delegate that represents the value factory.

    bool isThreadSafe

    A boolean value indicating whether the lazy initialization is thread-safe.

    AsyncLazy(Func<T>, LazyThreadSafetyMode)

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

    Declaration
    public AsyncLazy(Func<T> valueFactory, LazyThreadSafetyMode mode)
    Parameters
    Type Name Description
    Func<T> valueFactory

    The delegate that represents the value factory.

    LazyThreadSafetyMode mode

    The thread safety mode for the lazy initialization.

    AsyncLazy(T)

    Creates a new instance of the AsyncLazy<T> class with the specified value.

    Declaration
    public AsyncLazy(T value)
    Parameters
    Type Name Description
    T value

    The value to initialize the AsyncLazy<T> instance with.

    Properties

    IsValueCreated

    Determines whether the value has been created.

    Declaration
    public bool IsValueCreated { get; }
    Property Value
    Type Description
    bool

    Methods

    GetValueAsync()

    Gets a task that represents the asynchronous initialization of the value.

    Declaration
    public Task<T> GetValueAsync()
    Returns
    Type Description
    Task<T>

    A task that represents the asynchronous initialization of the value.

    Extension Methods

    LoggingExtensions.Log<T>(T)
    In this article
    DevToys logo © 2024 DevToys