Home
Manage Your Code
Snippet: Safely fire an event (C#)
Title: Safely fire an event Language: C#
Description: Ensures that an event can be fired even if there are no subscribers. Also avoids concurrency issues involved with checking the event for null before firing it. Views: 128
Author: Matt Schmidt Date Added: 8/15/2008
Copy Code  
1        /// <summary>
2        /// Fires when the monitors status changes.
3        /// </summary>
4        public event MonitorStatusEventHandler MonitorStatusChanged = delegate { };
Notes
Shamelessly stolen from http://blogs.msdn.com/jaybaz_MS/