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;
}

// When the Timer.Pause() method is called e.g:"myTimer.Pause()", the timer will display a dialog
// saying that that the timer has been paused
private async void MyTimer_TimerPaused(object sender, TimerEventArgs e)
{
            ContentDialog dialog = new ContentDialog();
            dialog.Title = "Timer Paused";
            dialog.Content = "The timer has been paused";
            dialog.CloseButtonText = "Continue";
            await dialog.ShowAsync();
}
Clone this wiki locally