views:

151

answers:

1

I tried to use object expression to extend the IDelegateEvent, but in fsi there was an error FS0039: The value or constructor 'handler' is not defined.

My codes are as follows:

type IDelegateEvent<'Del when 'Del:> Delegate> with
member this.Subscribe hanlder  = 
    do this.AddHandler(handler)
    { new IDisposable with 
        member x.Dispose() = 
            this.RemoveHandler(handler) }

And the reference is Matthew Podwysocki's Blog:http://weblogs.asp.net/podwysocki/archive/2009/08/21/f-first-class-events-creating-and-disposing-handlers.aspx

+2  A: 

Because of a spelling error hanlder =

Brian Rasmussen
Cool! Thanks ha~~
Alexander Guan