/// <summary> /// The method which raises the event. /// </summary> /// <param name="ticks"></param> protected void OnTimeElapsed(int ticks) { if (TimeElapsed != null) { TimeElapsedEventArgs e = new TimeElapsedEventArgs(ticks); TimeElapsed(this, e); } }
/// <summary> /// The method which raises the event. /// </summary> /// <param name="ticks"></param> protected void OnTimeElapsed(int ticks) { if (TimeElapsed != null) { TimeElapsedEventArgs e = new TimeElapsedEventArgs(ticks); TimeElapsed(this, e); } }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { _secondsLeft -= 1; if (_secondsLeft == 0) { Status = GameStatus.TimeOut; _timer.Stop(); _timer.Dispose(); TimeOutEventHandler TimeOutEventHandler = TimeOut; TimeOutEventHandler?.Invoke(this, new TimeOutEventArgs()); } var gameTimeElapsedEvent = new TimeElapsedEventArgs { SecondsLeft = _secondsLeft }; TimeElapsedEventHandler timeElapsedHandler = TimeElapsed; timeElapsedHandler?.Invoke(this, gameTimeElapsedEvent); }
static void timer_TimeElapsed(object sender, TimeElapsedEventArgs e) { Console.WriteLine("Timer interval has elapsed. Ticks left: {0}.", e.TicksLeft); }
/// <summary> /// Operation to register on event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="TimeElapsedEventArgs"/> instance containing the event data.</param> private void Do(object sender, TimeElapsedEventArgs e) { triggers.Add(Write(sender, e)); }
/// <summary> /// Writes the specified event arguments. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="TimeElapsedEventArgs"/> instance containing the event data.</param> /// <returns> /// Formatted string /// </returns> protected abstract string Write(object sender, TimeElapsedEventArgs e);
/// <inheritdoc /> /// <summary> /// Writes the specified event arguments. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="T:EventsObserver.TimeElapsedEventArgs" /> instance containing the event data.</param> /// <returns> /// Formatted string /// </returns> protected override string Write(object sender, TimeElapsedEventArgs e) => $"{nameof(SecondObserver)}: invoke #{++this.counter} at {e.InvokeTime:T}";
public void ProcessMessage(object sender, EventArgs args) { TimeElapsedEventArgs timeElapsedEventArgs = args as TimeElapsedEventArgs; System.Console.WriteLine($"Second listener gets message: {timeElapsedEventArgs.Message}"); }
static void timer_TimeElapsed(object sender, TimeElapsedEventArgs e) { Console.WriteLine("Timer interval has elapsed. Ticks left: {0}.", e.TicksLeft); }