protected virtual void OnRaiseRetryEvent(RetryEventArgs e) { // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. EventHandler<RetryEventArgs> handler = RaiseRetryEvent; // Event will be null if there are no subscribers. if (handler != null) { // Use the () operator to raise the event. handler(this, e); } }
/// <summary> /// Handles retry events. /// </summary> /// <param name="sender">The object that triggered the event.</param> /// <param name="e">Event data.</param> void HandleRetryEvent(object sender, RetryEventArgs e) { Console.WriteLine(String.Format("Retry {0}: {1}", e.CurrentRetryCount, e.LastException)); }