Observable.FromEvent<TDelegate, TEventArgs> Method (Action<TDelegate>, Action<TDelegate>)

Converts a .NET event to an observable sequence.

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


Public Shared Function FromEvent(Of TDelegate, TEventArgs) ( _
    addHandler As Action(Of TDelegate), _
    removeHandler As Action(Of TDelegate) _
) As IObservable(Of TEventArgs)
Dim addHandler As Action(Of TDelegate)
Dim removeHandler As Action(Of TDelegate)
Dim returnValue As IObservable(Of TEventArgs)

returnValue = Observable.FromEvent(addHandler, _
public static IObservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(
    Action<TDelegate> addHandler,
    Action<TDelegate> removeHandler
generic<typename TDelegate, typename TEventArgs>
static IObservable<TEventArgs>^ FromEvent(
    Action<TDelegate>^ addHandler, 
    Action<TDelegate>^ removeHandler
static member FromEvent : 
        addHandler:Action<'TDelegate> * 
        removeHandler:Action<'TDelegate> -> IObservable<'TEventArgs> 
JScript does not support generic types and methods.

Type Parameters

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


  • addHandler
    Type: System.Action<TDelegate>
    Action that attaches the given event handler to the underlying .NET event.
  • removeHandler
    Type: System.Action<TDelegate>
    Action that detaches the given event handler from the underlying .NET event.

Return Value

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

See Also


Observable Class

FromEvent Overload

System.Reactive.Linq Namespace