,System.IDisposable})} ,System.Action})} ,System.Threading.CancellationToken,System.Threading.Tasks.Task})} ,System.Threading.Tasks.Task})} ,System.Threading.CancellationToken,System.Threading.Tasks.Task{System.IDisposable}})} ,System.Threading.Tasks.Task{System.IDisposable}})} ,System.Threading.CancellationToken,System.Threading.Tasks.Task{System.Action}})} ,System.Threading.Tasks.Task{System.Action}})}
Observable.Create(Func, IDisposable>) method¶
Defined in
Type: Observable
Namespace: System.Reactive.Linq
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, IDisposable> subscribe) - 2.
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Action> subscribe) - 3.
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, CancellationToken, Task> subscribeAsync) - 4.
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Task> subscribeAsync) - 5.
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, CancellationToken, Task<IDisposable>> subscribeAsync) - 6.
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Task<IDisposable>> subscribeAsync) - 7.
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, CancellationToken, Task<Action>> subscribeAsync) - 8.
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Task<Action>> subscribeAsync)
1. Overload¶
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, IDisposable> subscribe)
Summary: Creates an observable sequence from a specified Subscribe method implementation.
Type parameters
| Name | Description |
|---|---|
TResult | The type of the elements in the produced sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
subscribe | Func | Implementation of the resulting observable sequence's Subscribe method. |
Returns: IObservable
Remarks
Use of this operator is preferred over manual implementation of the IObservable interface. In case you need a type implementing IObservable rather than an anonymous implementation, consider using the ObservableBase abstract base class.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | subscribe is null. |
2. Overload¶
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Action> subscribe)
Summary: Creates an observable sequence from a specified Subscribe method implementation.
Type parameters
| Name | Description |
|---|---|
TResult | The type of the elements in the produced sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
subscribe | Func | Implementation of the resulting observable sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable. |
Returns: IObservable
Remarks
Use of this operator is preferred over manual implementation of the IObservable interface. In case you need a type implementing IObservable rather than an anonymous implementation, consider using the ObservableBase abstract base class.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | subscribe is null. |
3. Overload¶
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, CancellationToken, Task> subscribeAsync)
Summary: Creates an observable sequence from a specified cancellable asynchronous Subscribe method. The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
Type parameters
| Name | Description |
|---|---|
TResult | The type of the elements in the produced sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
subscribeAsync | Func | Asynchronous method used to produce elements. |
Returns: IObservable
Remarks
When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | subscribeAsync is null. |
4. Overload¶
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Task> subscribeAsync)
Summary: Creates an observable sequence from a specified asynchronous Subscribe method.
Type parameters
| Name | Description |
|---|---|
TResult | The type of the elements in the produced sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
subscribeAsync | Func | Asynchronous method used to produce elements. |
Returns: IObservable
Remarks
This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | subscribeAsync is null. |
5. Overload¶
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, CancellationToken, Task<IDisposable>> subscribeAsync)
Summary: Creates an observable sequence from a specified cancellable asynchronous Subscribe method. The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
Type parameters
| Name | Description |
|---|---|
TResult | The type of the elements in the produced sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
subscribeAsync | Func | Asynchronous method used to implement the resulting sequence's Subscribe method. |
Returns: IObservable
Remarks
When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | subscribeAsync is null. |
6. Overload¶
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Task<IDisposable>> subscribeAsync)
Summary: Creates an observable sequence from a specified asynchronous Subscribe method.
Type parameters
| Name | Description |
|---|---|
TResult | The type of the elements in the produced sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
subscribeAsync | Func | Asynchronous method used to implement the resulting sequence's Subscribe method. |
Returns: IObservable
Remarks
This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | subscribeAsync is null. |
7. Overload¶
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, CancellationToken, Task<Action>> subscribeAsync)
Summary: Creates an observable sequence from a specified cancellable asynchronous Subscribe method. The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
Type parameters
| Name | Description |
|---|---|
TResult | The type of the elements in the produced sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
subscribeAsync | Func | Asynchronous method used to implement the resulting sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable. |
Returns: IObservable
Remarks
When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | subscribeAsync is null. |
8. Overload¶
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Task<Action>> subscribeAsync)
Summary: Creates an observable sequence from a specified asynchronous Subscribe method.
Type parameters
| Name | Description |
|---|---|
TResult | The type of the elements in the produced sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
subscribeAsync | Func | Asynchronous method used to implement the resulting sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable. |
Returns: IObservable
Remarks
This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | subscribeAsync is null. |