Share via


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

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

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

Syntax

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

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

Type Parameters

  • TEventArgs
    The type of event.

Parameters

  • addHandler
    Type: System.Action<EventHandler<TEventArgs>>
    The action that attaches the given event handler to the underlying .NET event.
  • removeHandler
    Type: System.Action<EventHandler<TEventArgs>>
    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