Re: Consuming your own events.

Sebastien Lambla <[email protected]> Wed, 30 Jan 2008 11:59:26 +0000
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <[email protected]>
I'm talking about using attached events that your type is not an owner of.
For example

public event MouseButtonEventHandler MouseDown
{
    add
    {
        this.AddHandler(Mouse.MouseDownEvent, value, false);
    }
    remove
    {
        this.RemoveHandler(Mouse.MouseDownEvent, value);
    }
}
 

Now let's see what the OnMouseDown method is.

protected virtual void OnMouseDown(MouseButtonEventArgs e)
{
}

Sparing you with the nasty details:
EventManager.RegisterClassHandler(typeof(UIElement), Mouse.MouseDownEvent,
new MouseButtonEventHandler(UIElement.OnMouseDownThunk), true);


So the next generation UI framework uses OnXxx for event handling (not
raising!). Raising itself uses the RaiseEvent method.

This conflicts with the guidelines that have been discussed, conflict less
with the ones i've just explained. Because of that, I advise against using
the On notation, to prevent the confusion introduced by different
frameworks...

--
SerialSeb
http://serialseb.blogspot.com


> -----Original Message-----
> From: Discussion of development on the .NET platform using any managed
> language [mailto:[email protected]] On Behalf Of Sébastien
> Lorion
> Sent: 30 January 2008 11:45
> To: [email protected]
> Subject: Re: [DOTNET-CLR] Consuming your own events.
> 
> On 1/30/08, Sebastien Lambla <[email protected]> wrote:
> >
> > When you start, like in WPF, using different property stores for your
> > events, the problem becomes even worse (and it's that problem that
> has
> > triggered my move to this new pattern).
> 
> 
> Could you elaborate on this bit, I am not sure I follow you. I think
> you mean to use a hashtable to associate events to their delegate
> instead of default
> storage (ie one field by event) ? If so, how is it affected by the
> OnXXX pattern ?
> 
> ===================================
> This list is hosted by DevelopMentor®  http://www.develop.com
> 
> View archives and manage your subscription(s) at
> http://discuss.develop.com

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

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