Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
On Methods Question
Message
De
28/07/2009 06:43:26
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
28/07/2009 05:11:38
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01414827
Message ID:
01415000
Vues:
28
There is a usual? :-) Just kidding Viv.

Actually, I find my self doing it different depending on the circumstance. I was thinking for true thread safety it needed to be more like this. Plus since it would be a prime suspect for being overriden in a subclass, I often create the EventArgs in this method if they are custom so there is oppotunity to change the function before the event is raised.
private void OnTrackerError(string message)
{
     // If we are not logging Errors, then just return
     LogMode mode = this.Settings.LoggingMode;
     if (mode == LogMode.None || mode == LogMode.NotificationOnly)
          return;

     TrackerActivityDelegate tad = this.TrackerError;
     if (tad != null)
     {
          // Raise the Event
          this.TrackerError(this, new TrackerActivityEventArgs(message, TrackerAction.Error));
     }
}
>Isn't the more usual format:
public virtual void OnTimerEvent( EventArgs e)
>{
>   if (this.TimerEvent != null)
>      this.TimerEvent(this, e);
>}
>
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform