Re: generic event handler

Steve Johnson <[email protected]> Tue, 28 Nov 2006 08:01:23 -0700
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <[email protected]>
On 11/28/06, Peter Osucha <[email protected]> wrote:
>
> I have reviewed the MSDN page on EventHandler<TEventArgs> now for the
> third
> time and I still don't understand the purpose (or maybe, where you would
> use) a generic event handler.  Can someone point me to a good link or give
> me short answer as to when you'd use this?



The short answer as to when you'd use this is: All the time :).

The purpose is to save you the trouble of declaring a new delegate for every
different event signature you have.  Usually, all that changes is the type
of EventArgs that are passed.  With the generic EventHandler, you can
declare all your events using the same handler...

EventHandler<MyEvent1Args>
EventHandler<MyEvent2Args>
...


...without having to declare a separate delegate for each.

--
Steve Johnson

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com