Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why is this happening??
Message
De
30/01/2009 09:57:28
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
30/01/2009 09:49:30
John Baird
Coatesville, Pennsylvanie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
01378204
Message ID:
01378467
Vues:
12
>>Hi John,
>>
>>>Hi Tim,
>>>
>>>That event structure you posted is the old method of doing it. .Net 3.5 introduced generic event handlers allowing you to do this (with all of the plumbing wired for you automatically):
>>>
>>>
>>>        public event EventHandler<NavBarGroupChangedEventArgs> NavBarGroupChanged;
>>>
>>>        /// <summary>
>>>        /// Triggers the NavBarGroupChanged event.
>>>        /// </summary>
>>>        public void RaiseNavBarGroupChanged(string group, string lastGroup, NavBarControl control)
>>>        {
>>>            var handler = this.NavBarGroupChanged;
>>>            if (handler != null)
>>>            {
>>>                handler(this, new NavBarGroupChangedEventArgs(group, lastGroup, control));
>>>            }
>>>        }
>>>
>>
>>That is cool, is the delegate the only thing not needed then?
>>Tim
>
>Correct, the delegate and wiring is done behind the scenes from what I understand.

I always thought typing a delegate just to define a signature was silly. Glad to know about this, Thanks!
I also wonder, several books, programmers name the delegate with a handler postfix. I never could grasp this and so I use delegate instead. Now mabey it makes more sense, but still not sure I see the significance of the word. Now the method at the subscriber could be called a handler and it would make sense to me, but that is not the case. Go figure.
Thanks again
Tim
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform