为什么我可以将两个参数传递给 Event class

Why can I pass two parameter to Event class

当我在f#

中查看事件class的定义时
type Event<'T> =
 class
  new Event : unit -> Event<'T>
  member this.Trigger : 'T -> unit
  member this.Publish :  IEvent<'T>
 end

我只能在事件 class 上传递一种类型,例如

let nameChanged = new Event<unit>()

但我也看到了一些示例,它传递了两个变量,例如

let propertyChanged = Event<PropertyChangedEventHandler, PropertyChangedEventArgs>()

这怎么可能?

当我实现像

这样的接口时
module SapHandler

open SAP.Middleware.Connector

type Connector() =

    let configurationChanged = Event<RfcDestinationManager.ConfigurationChangeHandler, RfcConfigurationEventArgs>()  

    interface IDestinationConfiguration with
        member self.ChangeEventsSupported() =
            false
        [<CLIEvent>]
        member self.ConfigurationChanged = configurationChanged.Publish

编译器抱怨:

The type 'RfcDestinationManager.ConfigurationChangeHandler' has a non-standard delegate type  

为什么?
委托类型的定义是:

有可能因为还有一个class too:

type Event<'Delegate,'Args (requires delegate)> =
 class
  new Event : unit -> Event<'Delegate,'Args>
  member this.Trigger : obj * 'Args -> unit
  member this.Publish :  IEvent<'Delegate,'Args>
 end

您收到该错误是因为您的事件委托可能缺少第一个 object sender 参数,这是 .net 中的标准参数。您可以使用 Control.DelegateEvent<'Delegate> 来绕过这个

let propertyChanged = DelegateEvent<RfcDestinationManager.ConfigurationChangeHandler>()