Imports System.Windows.Threading

Class MainWindow
  Private temporizador As DispatcherTimer
  Private tAntes As TimeSpan
  Private tDespues As TimeSpan

  Public Sub New()
    InitializeComponent()
    CrearTemporizador()
  End Sub

  Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs)
    tAntes = DateTime.Now.TimeOfDay
    temporizador.Interval = New TimeSpan(10000) ' 1 tick = 100 nanosegs.
  End Sub

  Private Sub CrearTemporizador()
    temporizador = New DispatcherTimer()
    temporizador.Interval = New TimeSpan(0, 0, 1)
    AddHandler temporizador.Tick, AddressOf Temporizador_Tick
    temporizador.Start()
  End Sub

  Private Sub Temporizador_Tick(sender As Object, e As EventArgs)
    etHora.Content = DateTime.Now.ToLongTimeString()
    tDespues = DateTime.Now.TimeOfDay
    System.Diagnostics.Debug.WriteLine(Convert.ToString((tDespues - tAntes).Milliseconds) & " mseg.")
    tAntes = tDespues
  End Sub
End Class
