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

    Show / Hide Table of Contents

    Class TaskExtensions

    Provides a set of helper method to play around with threads.

    Inheritance
    object
    TaskExtensions
    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 static class TaskExtensions

    Methods

    CompleteOnCurrentThread(Task)

    Gets the result of the task synchronously, on the current thread.

    Declaration
    public static void CompleteOnCurrentThread(this Task task)
    Parameters
    Type Name Description
    Task task

    The task to complete.

    CompleteOnCurrentThread<T>(Task<T>)

    Gets the result of the task synchronously, on the current thread.

    Declaration
    public static T CompleteOnCurrentThread<T>(this Task<T> task)
    Parameters
    Type Name Description
    Task<T> task

    The task to complete.

    Returns
    Type Description
    T

    The result of the task.

    Type Parameters
    Name Description
    T

    The type of the task result.

    Forget(Task)

    Runs a task without waiting for its result.

    Declaration
    public static void Forget(this Task _)
    Parameters
    Type Name Description
    Task _

    The task to run.

    Forget(ValueTask)

    Runs a task without waiting for its result.

    Declaration
    public static void Forget(this ValueTask _)
    Parameters
    Type Name Description
    ValueTask _

    The task to run.

    ForgetSafely(Task, Action<Exception>?)

    Runs a task without waiting for its result. Swallows or handle any exception caused by the task.

    Declaration
    public static void ForgetSafely(this Task task, Action<Exception>? errorHandler = null)
    Parameters
    Type Name Description
    Task task

    The task to run.

    Action<Exception> errorHandler

    The action to run when an exception is caught.

    ForgetSafely(ValueTask, Action<Exception>?)

    Runs a task without waiting for its result. Swallows or handle any exception caused by the task.

    Declaration
    public static void ForgetSafely(this ValueTask task, Action<Exception>? errorHandler = null)
    Parameters
    Type Name Description
    ValueTask task

    The task to run.

    Action<Exception> errorHandler

    The action to run when an exception is caught.

    Forget<T>(Task<T>)

    Runs a task without waiting for its result.

    Declaration
    public static void Forget<T>(this Task<T> _)
    Parameters
    Type Name Description
    Task<T> _

    The task to run.

    Type Parameters
    Name Description
    T

    The type of the task result.

    Forget<T>(ValueTask<T>)

    Runs a task without waiting for its result.

    Declaration
    public static void Forget<T>(this ValueTask<T> _)
    Parameters
    Type Name Description
    ValueTask<T> _

    The task to run.

    Type Parameters
    Name Description
    T

    The type of the task result.

    In this article
    DevToys logo © 2024 DevToys