Skip to content

)} ,System.Reactive.Concurrency.IScheduler)} ,System.Reactive.Concurrency.TaskObservationOptions)}

TaskObservableExtensions.ToObservable(Task) method

Defined in

Type: TaskObservableExtensions Namespace: System.Reactive.Threading.Tasks Assembly: System.Reactive.dll

Applies to

netstandard2.0

Overloads

  • 1. public static IObservable<Unit> ToObservable(this Task task)
  • 2. public static IObservable<Unit> ToObservable(this Task task, IScheduler scheduler)
  • 3. public static IObservable<Unit> ToObservable(this Task task, TaskObservationOptions options)
  • 4. public static IObservable<TResult> ToObservable<TResult>(this Task<TResult> task)
  • 5. public static IObservable<TResult> ToObservable<TResult>(this Task<TResult> task, IScheduler scheduler)
  • 6. public static IObservable<TResult> ToObservable<TResult>(this Task<TResult> task, TaskObservationOptions options)

1. Overload

public static IObservable<Unit> ToObservable(this Task task)

Summary: Returns an observable sequence that signals when the task completes.

Parameters

NameTypeDescription
taskTaskTask to convert to an observable sequence.

Returns: IObservable -- 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 instead.

Exceptions

TypeCondition
System.ArgumentNullExceptiontask is null.

2. Overload

public static IObservable<Unit> ToObservable(this Task task, IScheduler scheduler)

Summary: Returns an observable sequence that signals when the task completes.

Parameters

NameTypeDescription
taskTaskTask to convert to an observable sequence.
scheduler[IScheduler](#Scheduler on which to notify observers about completion, cancellation or failure.

Returns: IObservable -- 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 instead.

Exceptions

TypeCondition
System.ArgumentNullExceptiontask is null or scheduler is null.

3. Overload

public static IObservable<Unit> ToObservable(this Task task, TaskObservationOptions options)

Summary: Returns an observable sequence that signals when the task completes.

Parameters

NameTypeDescription
taskTaskTask to convert to an observable sequence.
options[TaskObservationOptions](#Controls how the tasks's progress is observed.

Returns: IObservable -- 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 instead.

Exceptions

TypeCondition
System.ArgumentNullExceptiontask is null.

4. Overload

public static IObservable<TResult> ToObservable<TResult>(this Task<TResult> task)

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

Type parameters

NameDescription
TResultThe type of the result produced by the task.

Parameters

NameTypeDescription
taskTaskTask to convert to an observable sequence.

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

Remarks

If the specified task object supports cancellation, consider using FromAsync instead.

Exceptions

TypeCondition
System.ArgumentNullExceptiontask is null.

5. Overload

public static IObservable<TResult> ToObservable<TResult>(this Task<TResult> task, IScheduler scheduler)

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

Type parameters

NameDescription
TResultThe type of the result produced by the task.

Parameters

NameTypeDescription
taskTaskTask to convert to an observable sequence.
scheduler[IScheduler](#Scheduler on which to notify observers about completion, cancellation or failure.

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

Remarks

If the specified task object supports cancellation, consider using FromAsync instead.

Exceptions

TypeCondition
System.ArgumentNullExceptiontask is null or scheduler is null.

6. Overload

public static IObservable<TResult> ToObservable<TResult>(this Task<TResult> task, TaskObservationOptions options)

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

Type parameters

NameDescription
TResultThe type of the result produced by the task.

Parameters

NameTypeDescription
taskTaskTask to convert to an observable sequence.
options[TaskObservationOptions](#Controls how the tasks's progress is observed.

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

Remarks

If the specified task object supports cancellation, consider using FromAsync instead.

Exceptions

TypeCondition
System.ArgumentNullExceptiontask is null.