I’m wanting to update a textblock in wpf form with a countdown timer on the press of a button.
At the moment it looks like the tick event of my DispatcherTimer is not being invoked.
This is the entirety of my code in vb.net
Private WithEvents tm5min As New DispatcherTimer
Private Sub BtnStart5_MouseDown(sender As Object, e As MouseButtonEventArgs) Handles BtnStart5.MouseDown
Try
tm5min.Interval = TimeSpan.FromMinutes(5)
tm5min.Start()
Debug.WriteLine("clock started with: " & tm5min.Interval.TotalMinutes)
Catch ex As Exception
Debug.Write(ex.Message)
End Try
End Sub
Private Sub tm5min_Tick(sender As Object, e As EventArgs) Handles tm5min.Tick
Debug.Write("I'm ticking")
TxtCountdown.Text = Date.Now.ToString("mm:ss")
End Sub
New contributor
bcummins77 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.