I am curious as to how other developers use delegates and/or events other than for responding to UI events? I, personally, don’t use them for anything other than responding to UI events but I have a strong feeling that I am missing out on the power of delegates and events. So I pose this question to the SO community so that I may get some ideas on how I could possibly add these tools to my arsenal.
Share
Events are pretty mundane. Most often you’ll be using them in response to UI or when developing components that have to inform users about state changes. Yawn.
Delegates, however, are full of awesome and win. Probably the most common use is in Linq. Linq uses lambdas all over the place, which are shorthand delegates.
Another common use is in multithreading:
Where I’ve used them that I like the most is in HtmlHelper extension methods that mix rendering html with codebehind:
an example of its use in an aspx file: