I am trying to publish an event from an F# type, but I want it to be seen as an event from C# or VB. It seems that the correct way to do it used to be IEvent.create_HandlerEvent, but this function doesn't exist in the newest version of F#. So what is the correct way to do it now?
Events are not my forte, but this example seems to work on F# 1.9.6.16:
namespace EventExample
open System
type MyEventArgs(msg:string) =
inherit EventArgs()
member this.Message = msg
type MyEventDelegate = delegate of obj * MyEventArgs -> unit
type Foo() =
let ev = new Event<MyEventDelegate, MyEventArgs>()
member this.Ping(msg) =
ev.Trigger(this, new MyEventArgs(msg))
[<CLIEvent>]
member this.GotPinged = ev.Publish
See also
http://cs.hubfs.net/forums/thread/10555.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With