This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
Callbacks
Delegates, Interfaces and Events can each be used to provide callback functionality. Each has it’s own specific usage characteristics that make it better suited to particular situations.
Do use Events if:
- One signs up for the callback up front (typically through a separate Add and Remove methods
- Typically more than one object will care
Do use a Delegate if:
- You basically want a C style function pointer.
- Single callback
- Registered in the call or at construction time (not through separate Add method)
Do use an Interface if:
- The callback entails complex behavior
- We should have an example of each