20
Delegates
·Delegates are used for callbacks:
–In response to some event they invoke one or more functions supplied to them.
–Library code that generates an event will define a delegate for application developers to use – the developer defines application specific processing that needs to occur in response to an event generated by the library code.
–A delegate defines one specific function signature to use:

  public delegate rtnType delFun(args…);

This declares a new type, delFun that invokes functions with that signature.
–The developer supplies functions this way:

     libClass.delFun myDel =
  new libClass.delFun(myFun);

This declares a new instance, myDel, of the delFun type.