Skip to content

Page 4: Timer Events

Colin Kiama edited this page Jan 15, 2018 · 9 revisions

Events Available:

TimerEnded - Event that occurs when the timer has finished

TimerTicked - Event that occurs when an interval has passed.

TimerReset - Event that occurs when the timer has been reset.

TimerPaused - Event that occurs when the timer has been paused.

TimerStarted - Event that occurs when the timer starts.

How to use them:

// Create a timer
Timer myTimer = new Timer();

// Suscribe to an event in the constructor of a class 
public MainPage()
{
   myTimer.TimerPaused += MyTimer_TimerPaused;
}

// Code that runs when the event happens
private async void MyTimer_TimerPaused(object sender, TimerEventArgs e)
{
   ContentDialog myDialog = new ContentDialog();
   myDialog.Title = "Timer Paused";
   myDialog.Content = "The timer has been paused";
   myDialog.CloseButtonText = "Continue";
   await myDialog.ShowAsync();
}
Clone this wiki locally