共用方式為


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

將符合標準 .NET 事件模式的 .NET 事件轉換為具有指定轉換的可觀察序列、新增處理常式和移除處理常式。

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

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.

類型參數

  • TDelegate
    委派的類型。
  • TEventArgs
    事件的類型。

參數

  • 轉換
    類型:System.Func<EventHandler< TEventArgs > 、TDelegate>
    函式,用來將指定的事件處理常式轉換為與基礎 .NET 事件相容的委派。
  • addHandler
    類型:System.Action< TDelegate>
    將指定事件處理常式附加至基礎 .NET 事件的動作。
  • removeHandler
    類型:System.Action< TDelegate>
    將指定事件處理常式與基礎 .NET 事件中斷連結的動作。

傳回值

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

另請參閱

參考

Observable 類別

FromEventPattern 多載

System.Reactive.Linq 命名空間