Skip to content

},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

NameDescription
TResultThe type of the elements in the produced sequence.
TResourceThe type of the resource used during the generation of the resulting sequence. Needs to implement IDisposable.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
resourceFactoryExpression>Factory function to obtain a resource object.
observableFactoryExpression>>Factory function to obtain an observable sequence that depends on the obtained resource.

Returns: IQbservable -- An observable sequence whose lifetime controls the lifetime of the dependent resource object.

Exceptions

TypeCondition
System.ArgumentNullExceptionresourceFactory 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

NameDescription
TResultThe type of the elements in the produced sequence.
TResourceThe type of the resource used during the generation of the resulting sequence. Needs to implement IDisposable.

Parameters

NameTypeDescription
provider[IQbservableProvider](#Query provider used to construct the [IQbservable](# data source.
resourceFactoryAsyncExpression>>Asynchronous factory function to obtain a resource object.
observableFactoryAsyncExpression>>>Asynchronous factory function to obtain an observable sequence that depends on the obtained resource.

Returns: IQbservable -- An observable sequence whose lifetime controls the lifetime of the dependent resource object.

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

TypeCondition
System.ArgumentNullExceptionresourceFactoryAsync or observableFactoryAsync is null.