Search Results for

    Show / Hide Table of Contents

    Class TaskObservableExtensions

    Provides a set of static methods for converting tasks to observable sequences.

    Inheritance
    Object
    TaskObservableExtensions
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ToString()
    Object.ReferenceEquals(Object, Object)
    Namespace: System.Reactive.Threading.Tasks
    Assembly: System.Reactive.Linq.dll
    Syntax
    public static class TaskObservableExtensions

    Methods

    | Improve this Doc View Source

    ToObservable(Task)

    Returns an observable sequence that signals when the task completes.

    Declaration
    public static IObservable<Unit> ToObservable(this Task task)
    Parameters
    Type Name Description
    Task task

    Task to convert to an observable sequence.

    Returns
    Type Description
    IObservable<Unit>

    An observable sequence that produces a unit value when the task completes, or propagates the exception produced by the task.

    Remarks

    If the specified task object supports cancellation, consider using FromAsync(Func<CancellationToken, Task>) instead.

    Exceptions
    Type Condition
    ArgumentNullException

    task is null.

    | Improve this Doc View Source

    ToObservable<TResult>(Task<TResult>)

    Returns an observable sequence that propagates the result of the task.

    Declaration
    public static IObservable<TResult> ToObservable<TResult>(this Task<TResult> task)
    Parameters
    Type Name Description
    Task<TResult> task

    Task to convert to an observable sequence.

    Returns
    Type Description
    IObservable<TResult>

    An observable sequence that produces the task's result, or propagates the exception produced by the task.

    Type Parameters
    Name Description
    TResult

    The type of the result produced by the task.

    Remarks

    If the specified task object supports cancellation, consider using FromAsync<TResult>(Func<CancellationToken, Task<TResult>>) instead.

    Exceptions
    Type Condition
    ArgumentNullException

    task is null.

    | Improve this Doc View Source

    ToTask<TResult>(IObservable<TResult>)

    Returns a task that will receive the last value or the exception produced by the observable sequence.

    Declaration
    public static Task<TResult> ToTask<TResult>(this IObservable<TResult> observable)
    Parameters
    Type Name Description
    IObservable<TResult> observable

    Observable sequence to convert to a task.

    Returns
    Type Description
    Task<TResult>

    A task that will receive the last element or the exception produced by the observable sequence.

    Type Parameters
    Name Description
    TResult

    The type of the elements in the source sequence.

    Exceptions
    Type Condition
    ArgumentNullException

    observable is null.

    | Improve this Doc View Source

    ToTask<TResult>(IObservable<TResult>, Object)

    Returns a task that will receive the last value or the exception produced by the observable sequence.

    Declaration
    public static Task<TResult> ToTask<TResult>(this IObservable<TResult> observable, object state)
    Parameters
    Type Name Description
    IObservable<TResult> observable

    Observable sequence to convert to a task.

    Object state

    The state to use as the underlying task's AsyncState.

    Returns
    Type Description
    Task<TResult>

    A task that will receive the last element or the exception produced by the observable sequence.

    Type Parameters
    Name Description
    TResult

    The type of the elements in the source sequence.

    Exceptions
    Type Condition
    ArgumentNullException

    observable is null.

    | Improve this Doc View Source

    ToTask<TResult>(IObservable<TResult>, CancellationToken)

    Returns a task that will receive the last value or the exception produced by the observable sequence.

    Declaration
    public static Task<TResult> ToTask<TResult>(this IObservable<TResult> observable, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    IObservable<TResult> observable

    Observable sequence to convert to a task.

    CancellationToken cancellationToken

    Cancellation token that can be used to cancel the task, causing unsubscription from the observable sequence.

    Returns
    Type Description
    Task<TResult>

    A task that will receive the last element or the exception produced by the observable sequence.

    Type Parameters
    Name Description
    TResult

    The type of the elements in the source sequence.

    Exceptions
    Type Condition
    ArgumentNullException

    observable is null.

    | Improve this Doc View Source

    ToTask<TResult>(IObservable<TResult>, CancellationToken, Object)

    Returns a task that will receive the last value or the exception produced by the observable sequence.

    Declaration
    public static Task<TResult> ToTask<TResult>(this IObservable<TResult> observable, CancellationToken cancellationToken, object state)
    Parameters
    Type Name Description
    IObservable<TResult> observable

    Observable sequence to convert to a task.

    CancellationToken cancellationToken

    Cancellation token that can be used to cancel the task, causing unsubscription from the observable sequence.

    Object state

    The state to use as the underlying task's AsyncState.

    Returns
    Type Description
    Task<TResult>

    A task that will receive the last element or the exception produced by the observable sequence.

    Type Parameters
    Name Description
    TResult

    The type of the elements in the source sequence.

    Exceptions
    Type Condition
    ArgumentNullException

    observable is null.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX