Export (0) Print
Expand All
3 out of 6 rated this helpful - Rate this topic

Callback Function Usage

.NET Framework 1.1

Delegates, Interfaces and Events allow you to provide callback functionality. Each type has its own specific usage characteristics that make it better suited to particular situations.

Events

Use an event if the following are true:

  • A method signs up for the callback function up front, typically through separate Add and Remove methods.
  • Typically, more than one object will want notification of the event.
  • You want end users to be able to easily add a listener to the notification in the visual designer.

Delegates

Use a delegate if the following are true:

  • You want a C language style function pointer.
  • You want a single callback function.
  • You want registration to occur in the call or at construction time, not through a separate Add method.

Interfaces

Use an interface if the callback function requires complex behavior.

See Also

Design Guidelines for Class Library Developers

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.