Skip to content

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

Observable.FromAsync(Func>) method

Defined in

Type: Observable Namespace: System.Reactive.Linq Assembly: System.Reactive.dll

Applies to

netstandard2.0

Overloads

  • 1. public static IObservable<TResult> FromAsync<TResult>(Func<Task<TResult>> functionAsync)
  • 2. public static IObservable<TResult> FromAsync<TResult>(Func<Task<TResult>> functionAsync, IScheduler scheduler)
  • 3. public static IObservable<TResult> FromAsync<TResult>(Func<Task<TResult>> functionAsync, TaskObservationOptions options)
  • 4. public static IObservable<TResult> FromAsync<TResult>(Func<CancellationToken, Task<TResult>> functionAsync)
  • 5. public static IObservable<TResult> FromAsync<TResult>(Func<CancellationToken, Task<TResult>> functionAsync, IScheduler scheduler)
  • 6. public static IObservable<TResult> FromAsync<TResult>(Func<CancellationToken, Task<TResult>> functionAsync, TaskObservationOptions options)
  • 7. public static IObservable<Unit> FromAsync(Func<Task> actionAsync)
  • 8. public static IObservable<Unit> FromAsync(Func<Task> actionAsync, IScheduler scheduler)
  • 9. public static IObservable<Unit> FromAsync(Func<Task> actionAsync, TaskObservationOptions options)
  • 10. public static IObservable<Unit> FromAsync(Func<CancellationToken, Task> actionAsync)
  • 11. public static IObservable<Unit> FromAsync(Func<CancellationToken, Task> actionAsync, IScheduler scheduler)
  • 12. public static IObservable<Unit> FromAsync(Func<CancellationToken, Task> actionAsync, TaskObservationOptions options)

1. Overload

public static IObservable<TResult> FromAsync<TResult>(Func<Task<TResult>> functionAsync)

Summary: Converts an asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.

Type parameters

NameDescription
TResultThe type of the result returned by the asynchronous function.

Parameters

NameTypeDescription
functionAsyncFunc>Asynchronous function to convert.

Returns: IObservable -- An observable sequence exposing the result of invoking the function, or an exception.

Exceptions

TypeCondition
System.ArgumentNullExceptionfunctionAsync is null.

2. Overload

public static IObservable<TResult> FromAsync<TResult>(Func<Task<TResult>> functionAsync, IScheduler scheduler)

Summary: Converts an asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.

Type parameters

NameDescription
TResultThe type of the result returned by the asynchronous function.

Parameters

NameTypeDescription
functionAsyncFunc>Asynchronous function to convert.
scheduler[IScheduler](#Scheduler on which to notify observers.

Returns: IObservable -- An observable sequence exposing the result of invoking the function, or an exception.

Exceptions

TypeCondition
System.ArgumentNullExceptionfunctionAsync is null or scheduler is null.

3. Overload

public static IObservable<TResult> FromAsync<TResult>(Func<Task<TResult>> functionAsync, TaskObservationOptions options)

Summary: Converts an asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.

Type parameters

NameDescription
TResultThe type of the result returned by the asynchronous function.

Parameters

NameTypeDescription
functionAsyncFunc>Asynchronous function to convert.
options[TaskObservationOptions](#Controls how the tasks's progress is observed.

Returns: IObservable -- An observable sequence exposing the result of invoking the function, or an exception.

Exceptions

TypeCondition
System.ArgumentNullExceptionfunctionAsync is null.

4. Overload

public static IObservable<TResult> FromAsync<TResult>(Func<CancellationToken, Task<TResult>> functionAsync)

Summary: Converts an asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started. The CancellationToken passed to the asynchronous function is tied to the observable sequence's subscription that triggered the function's invocation and can be used for best-effort cancellation.

Type parameters

NameDescription
TResultThe type of the result returned by the asynchronous function.

Parameters

NameTypeDescription
functionAsyncFunc>Asynchronous function to convert.

Returns: IObservable -- An observable sequence exposing the result of invoking the function, or an exception.

Remarks

When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.

Exceptions

TypeCondition
System.ArgumentNullExceptionfunctionAsync is null.

5. Overload

public static IObservable<TResult> FromAsync<TResult>(Func<CancellationToken, Task<TResult>> functionAsync, IScheduler scheduler)

Summary: Converts an asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started. The CancellationToken passed to the asynchronous function is tied to the observable sequence's subscription that triggered the function's invocation and can be used for best-effort cancellation.

Type parameters

NameDescription
TResultThe type of the result returned by the asynchronous function.

Parameters

NameTypeDescription
functionAsyncFunc>Asynchronous function to convert.
scheduler[IScheduler](#Scheduler on which to notify observers.

Returns: IObservable -- An observable sequence exposing the result of invoking the function, or an exception.

Remarks

When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.

Exceptions

TypeCondition
System.ArgumentNullExceptionfunctionAsync is null or scheduler is null.

6. Overload

public static IObservable<TResult> FromAsync<TResult>(Func<CancellationToken, Task<TResult>> functionAsync, TaskObservationOptions options)

Summary: Converts an asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started. The CancellationToken passed to the asynchronous function is tied to the observable sequence's subscription that triggered the function's invocation and can be used for best-effort cancellation.

Type parameters

NameDescription
TResultThe type of the result returned by the asynchronous function.

Parameters

NameTypeDescription
functionAsyncFunc>Asynchronous function to convert.
options[TaskObservationOptions](#Controls how the tasks's progress is observed.

Returns: IObservable -- An observable sequence exposing the result of invoking the function, or an exception.

Remarks

When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.

Exceptions

TypeCondition
System.ArgumentNullExceptionfunctionAsync is null.

7. Overload

public static IObservable<Unit> FromAsync(Func<Task> actionAsync)

Summary: Converts an asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.

Parameters

NameTypeDescription
actionAsyncFuncAsynchronous action to convert.

Returns: IObservable -- An observable sequence exposing a Unit value upon completion of the action, or an exception.

Exceptions

TypeCondition
System.ArgumentNullExceptionactionAsync is null.

8. Overload

public static IObservable<Unit> FromAsync(Func<Task> actionAsync, IScheduler scheduler)

Summary: Converts an asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.

Parameters

NameTypeDescription
actionAsyncFuncAsynchronous action to convert.
scheduler[IScheduler](#Scheduler on which to notify observers.

Returns: IObservable -- An observable sequence exposing a Unit value upon completion of the action, or an exception.

Exceptions

TypeCondition
System.ArgumentNullExceptionactionAsync is null or scheduler is null.

9. Overload

public static IObservable<Unit> FromAsync(Func<Task> actionAsync, TaskObservationOptions options)

Summary: Converts an asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.

Parameters

NameTypeDescription
actionAsyncFuncAsynchronous action to convert.
options[TaskObservationOptions](#Controls how the tasks's progress is observed.

Returns: IObservable -- An observable sequence exposing a Unit value upon completion of the action, or an exception.

Exceptions

TypeCondition
System.ArgumentNullExceptionactionAsync is null.

10. Overload

public static IObservable<Unit> FromAsync(Func<CancellationToken, Task> actionAsync)

Summary: Converts an asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started. The CancellationToken passed to the asynchronous action is tied to the observable sequence's subscription that triggered the action's invocation and can be used for best-effort cancellation.

Parameters

NameTypeDescription
actionAsyncFuncAsynchronous action to convert.

Returns: IObservable -- An observable sequence exposing a Unit value upon completion of the action, or an exception.

Remarks

When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.

Exceptions

TypeCondition
System.ArgumentNullExceptionactionAsync is null.

11. Overload

public static IObservable<Unit> FromAsync(Func<CancellationToken, Task> actionAsync, IScheduler scheduler)

Summary: Converts an asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started. The CancellationToken passed to the asynchronous action is tied to the observable sequence's subscription that triggered the action's invocation and can be used for best-effort cancellation.

Parameters

NameTypeDescription
actionAsyncFuncAsynchronous action to convert.
scheduler[IScheduler](#Scheduler on which to notify observers.

Returns: IObservable -- An observable sequence exposing a Unit value upon completion of the action, or an exception.

Remarks

When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.

Exceptions

TypeCondition
System.ArgumentNullExceptionactionAsync is null or scheduler is null.

12. Overload

public static IObservable<Unit> FromAsync(Func<CancellationToken, Task> actionAsync, TaskObservationOptions options)

Summary: Converts an asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started. The CancellationToken passed to the asynchronous action is tied to the observable sequence's subscription that triggered the action's invocation and can be used for best-effort cancellation.

Parameters

NameTypeDescription
actionAsyncFuncAsynchronous action to convert.
options[TaskObservationOptions](#Controls how the tasks's progress is observed.

Returns: IObservable -- An observable sequence exposing a Unit value upon completion of the action, or an exception.

Remarks

When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.

Exceptions

TypeCondition
System.ArgumentNullExceptionactionAsync is null.