},System.Linq.Expressions.Expression{System.Func{--1,System.IObservable{--0}}})} }},System.Linq.Expressions.Expression{System.Func{--1,System.Threading.CancellationToken,System.Threading.Tasks.Task{System.IObservable{--0}}}})}
Qbservable.Using(IQbservableProvider, Expression>, Expression>>) method¶
Defined in
Type: Qbservable
Namespace: System.Reactive.Linq
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<TResource>> resourceFactory, Expression<Func<TResource, IObservable<TResult>>> observableFactory) where TResource : IDisposable - 2.
public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResource>>> resourceFactoryAsync, Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync) where TResource : IDisposable
1. Overload¶
public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<TResource>> resourceFactory, Expression<Func<TResource, IObservable<TResult>>> observableFactory) where TResource : IDisposable
Summary: Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
Type parameters
| Name | Description |
|---|---|
TResult | The type of the elements in the produced sequence. |
TResource | The type of the resource used during the generation of the resulting sequence. Needs to implement IDisposable. |
Parameters
| Name | Type | Description |
|---|---|---|
provider | [IQbservableProvider](# | Query provider used to construct the [IQbservable](# data source. |
resourceFactory | Expression | Factory function to obtain a resource object. |
observableFactory | Expression | Factory function to obtain an observable sequence that depends on the obtained resource. |
Returns: IQbservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | resourceFactory or observableFactory is null. |
2. Overload¶
public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResource>>> resourceFactoryAsync, Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync) where TResource : IDisposable
Summary: Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime. The resource is obtained and used through asynchronous methods. The CancellationToken passed to the asynchronous methods is tied to the returned disposable subscription, allowing best-effort cancellation at any stage of the resource acquisition or usage.
Type parameters
| Name | Description |
|---|---|
TResult | The type of the elements in the produced sequence. |
TResource | The type of the resource used during the generation of the resulting sequence. Needs to implement IDisposable. |
Parameters
| Name | Type | Description |
|---|---|---|
provider | [IQbservableProvider](# | Query provider used to construct the [IQbservable](# data source. |
resourceFactoryAsync | Expression | Asynchronous factory function to obtain a resource object. |
observableFactoryAsync | Expression | Asynchronous factory function to obtain an observable sequence that depends on the obtained resource. |
Returns: IQbservable
Remarks
When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous resource factory and observable factory functions will be signaled.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | resourceFactoryAsync or observableFactoryAsync is null. |