Partilhar via


Observable.Using<TSource, Método TResource>

Constrói uma sequência observável que depende de um objeto de recurso.

Namespace:System.Reactive.Linq
Assembly: System.Reactive (em System.Reactive.dll)

Sintaxe

'Declaration
Public Shared Function Using(Of TSource, TResource As IDisposable) ( _
    resourceFactory As Func(Of TResource), _
    observableFactory As Func(Of TResource, IObservable(Of TSource)) _
) As IObservable(Of TSource)
'Usage
Dim resourceFactory As Func(Of TResource)
Dim observableFactory As Func(Of TResource, IObservable(Of TSource))
Dim returnValue As IObservable(Of TSource)

returnValue = Observable.Using(resourceFactory, _
    observableFactory)
public static IObservable<TSource> Using<TSource, TResource>(
    Func<TResource> resourceFactory,
    Func<TResource, IObservable<TSource>> observableFactory
)
where TResource : IDisposable
public:
generic<typename TSource, typename TResource>
where TResource : IDisposable
static IObservable<TSource>^ Using(
    Func<TResource>^ resourceFactory, 
    Func<TResource, IObservable<TSource>^>^ observableFactory
)
static member Using : 
        resourceFactory:Func<'TResource> * 
        observableFactory:Func<'TResource, IObservable<'TSource>> -> IObservable<'TSource>  when 'TResource : IDisposable
JScript does not support generic types and methods.

Parâmetros de tipo

  • TSource
    O tipo de fonte.
  • TResource
    O tipo de recurso.

Parâmetros

  • resourceFactory
    Tipo: System.Func<TResource>
    A função de fábrica para obter um objeto de recurso.
  • observableFactory
    Tipo: System.Func<TResource, IObservable<TSource>>
    A função de fábrica para obter uma sequência observável que depende do recurso obtido.

Valor Retornado

Tipo: System.IObservable<TSource>
A sequência observável cujo tempo de vida controla o tempo de vida do objeto de recurso dependente.

Consulte Também

Referência

Classe observável

System.Reactive.Linq Namespace