Class MainWindow 
  Private temporizador As System.Timers.Timer
  Private tAntes As TimeSpan
  Private tDespues As TimeSpan

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

  Private Sub CrearTemporizador()
    temporizador = New System.Timers.Timer()
    temporizador.Interval = 1000
    AddHandler temporizador.Elapsed, AddressOf Temporizador_Elapsed
    temporizador.Enabled = True
  End Sub

  Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs)
    tAntes = DateTime.Now.TimeOfDay
    temporizador.Interval = 1 ' milisegundo
  End Sub

  Private Sub Temporizador_Elapsed(sender As Object, e As System.Timers.ElapsedEventArgs)
    Dispatcher.BeginInvoke(New Action(AddressOf ActualizarReloj))
    tDespues = DateTime.Now.TimeOfDay
    System.Diagnostics.Debug.WriteLine(Convert.ToString((tDespues - tAntes).Milliseconds) & " mseg.")
    tAntes = tDespues
  End Sub

  Private Sub ActualizarReloj()
    etHora.Content = DateTime.Now.ToLongTimeString() ' hora actual
  End Sub
End Class
