using System; namespace RGB.NET.Core { public static partial class RGBSurface { #region EventHandler /// /// Represents the event-handler of the -event. /// /// The arguments provided by the event. public delegate void ExceptionEventHandler(ExceptionEventArgs args); /// /// Represents the event-handler of the -event. /// /// The arguments provided by the event. public delegate void UpdatingEventHandler(UpdatingEventArgs args); /// /// Represents the event-handler of the -event. /// /// The arguments provided by the event. public delegate void UpdatedEventHandler(UpdatedEventArgs args); #endregion #region Events // ReSharper disable EventNeverSubscribedTo.Global /// /// Occurs when a catched exception is thrown inside the . /// public static event ExceptionEventHandler Exception; /// /// Occurs when the starts updating. /// public static event UpdatingEventHandler Updating; /// /// Occurs when the update is done. /// public static event UpdatedEventHandler Updated; // ReSharper restore EventNeverSubscribedTo.Global #endregion #region Methods /// /// Handles the needed event-calls for an exception. /// /// The exception previously thrown. private static void OnException(Exception ex) { try { Exception?.Invoke(new ExceptionEventArgs(ex)); } catch { /* Well ... that's not my fault */ } } /// /// Handles the needed event-calls before updating. /// private static void OnUpdating() { try { long lastUpdateTicks = _lastUpdate.Ticks; _lastUpdate = DateTime.Now; Updating?.Invoke(new UpdatingEventArgs((DateTime.Now.Ticks - lastUpdateTicks) / 10000000.0)); } catch { /* Well ... that's not my fault */ } } /// /// Handles the needed event-calls after an update. /// private static void OnUpdated() { try { Updated?.Invoke(new UpdatedEventArgs()); } catch { /* Well ... that's not my fault */ } } #endregion } }