F# IEvent.create
Where is it gone ?
let triggerFindNext,findNextEvent = IEvent.create<EventArgs>()
The field, constructor or member 'create'开发者_开发问答 is not defined
maybe I must to add some Framework for it ?
The IEvent.create
function has been deprecated. A new way of creating events is to create instance of the Event
type. In the simplest case you can write just this:
let evt = new Event<EventArgs>()
// Trigger event (instead of first element of the tuple)
evt.Trigger()
// Returns IEvent<EventArgs> value (instead of second element of the tuple)
evt.Publish
This represents event using IEvent<_>
value (and doesn't generate .NET compatible event if you expose it as a property) and it uses generic Handler<_>
delegate from F# libraries.
(If you want to generate .NET compatible event usable from C# then you need to add CLIEvent
attribute and you can use variant of Event
that takes delegate as generic parameter as described in the answer already mentioned by others)
EDIT: I posted a more complete F# snippet (with nicer formatting) here: http://fssnip.net/1d
精彩评论