Define event

Category:
Event
Description: Define F# event
Code:
let defineEvent() = 
let e = new Event()
//trigger event, but not subscriber. Nothing happens.
e.Trigger(5)
//subscribe to the event
Event.add (fun n->printfn "%d" n) e.Publish
//trigger the event again
e.Trigger(10);

Execution Result:
10

Last edited Sep 12, 2011 at 11:20 PM by ttliu2000, version 2

Comments

No comments yet.