- The Takeaway
- Getting the Picture
- A Callback Interface
- The C# Code
- Putting It All Together
- Callbacks Versus Delegates
- Conclusion
Callbacks Versus Delegates
So, you've seen the use of raw C# callbacks and in my earlier article I used delegates for the same purpose. When should you use one instead of the other? Like anything, it's largely a matter of taste. I found the callback interface approach somewhat easier to understand because it's a lower level mechanism than delegates. If the callback approach is more intuitively understood, then it might make for more maintainable code. On the other hand, using delegates is a higher-level approach and they can be extended to provide multicasting. Another aspect of the callback approach that I like is the ability to detach from incoming events. Have a look at the code and see what you think.