共用方式為


Observable.FromEvent TEventArgs 方法 (Action Action << TEventArgs >> , Action Action << TEventArgs >>) <>

將 .NET 事件轉換為可觀察的序列。

Namespace:System.Reactive.Linq
裝配: System.Reactive.dll) 中的 System.Reactive (

Syntax

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

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

類型參數

  • TEventArgs
    事件的類型。

參數

  • addHandler
    類型:System.Action Action<< TEventArgs>>
    將指定事件處理常式附加至基礎 .NET 事件的動作。
  • removeHandler
    類型:System.Action Action<< TEventArgs>>
    從基礎 .NET 事件中斷連結指定事件處理常式的動作。

傳回值

類型:System.IObservable< TEventArgs>
可觀察序列,其中包含基礎 .NET 事件調用的資料表示。

另請參閱

參考

Observable 類別

FromEvent 多載

System.Reactive.Linq 命名空間