Bagikan melalui


Observable.FromEventPattern<TDelegate, TEventArgs> Method (Func<EventHandler<TEventArgs>, TDelegate>, Action<TDelegate>, Action<TDelegate>)

Converts a .NET event, conforming to the standard .NET event pattern, to an observable sequence with the specified conversion, add handler and remove handler.

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

Syntax

'Declaration
Public Shared Function FromEventPattern(Of TDelegate, TEventArgs As EventArgs) ( _
    conversion As Func(Of EventHandler(Of TEventArgs), TDelegate), _
    addHandler As Action(Of TDelegate), _
    removeHandler As Action(Of TDelegate) _
) As IObservable(Of EventPattern(Of TEventArgs))
'Usage
Dim conversion As Func(Of EventHandler(Of TEventArgs), TDelegate)
Dim addHandler As Action(Of TDelegate)
Dim removeHandler As Action(Of TDelegate)
Dim returnValue As IObservable(Of EventPattern(Of TEventArgs))

returnValue = Observable.FromEventPattern(conversion, _
    addHandler, removeHandler)
public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(
    Func<EventHandler<TEventArgs>, TDelegate> conversion,
    Action<TDelegate> addHandler,
    Action<TDelegate> removeHandler
)
where TEventArgs : EventArgs
public:
generic<typename TDelegate, typename TEventArgs>
where TEventArgs : EventArgs
static IObservable<EventPattern<TEventArgs>^>^ FromEventPattern(
    Func<EventHandler<TEventArgs>^, TDelegate>^ conversion, 
    Action<TDelegate>^ addHandler, 
    Action<TDelegate>^ removeHandler
)
static member FromEventPattern : 
        conversion:Func<EventHandler<'TEventArgs>, 'TDelegate> * 
        addHandler:Action<'TDelegate> * 
        removeHandler:Action<'TDelegate> -> IObservable<EventPattern<'TEventArgs>>  when 'TEventArgs : EventArgs
JScript does not support generic types and methods.

Type Parameters

  • TDelegate
    The type of delegate.
  • TEventArgs
    The type of event.

Parameters

  • conversion
    Type: System.Func<EventHandler<TEventArgs>, TDelegate>
    A function used to convert the given event handler to a delegate compatible with the underlying .NET event.
  • addHandler
    Type: System.Action<TDelegate>
    The action that attaches the given event handler to the underlying .NET event.
  • removeHandler
    Type: System.Action<TDelegate>
    The action that detaches the given event handler from the underlying .NET event.

Return Value

Type: System.IObservable<EventPattern<TEventArgs>>
The observable sequence that contains data representations of invocations of the underlying .NET event.

See Also

Reference

Observable Class

FromEventPattern Overload

System.Reactive.Linq Namespace