Re: generic event handler

Peter Osucha <[email protected]> Tue, 28 Nov 2006 10:38:57 -0500
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <[email protected]>
Thank you, Steve.  I have found myself using generic collections for all my
collection classes so I thought that generic event handlers might also be
used 'all the time'.  Your comments on usage were helpful too - I guess I'll
go read the MSDN stuff for the fourth time... ;-)

Peter


> -----Original Message-----
> From: Discussion relating to the specifics of the C# and
> Managed C++ languages [mailto:[email protected]]
> On Behalf Of Steve Johnson
> Sent: Tuesday, November 28, 2006 10:01 AM
> To: [email protected]
> Subject: Re: [DOTNET-CX] generic event handler
>
> 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