Timer
Timer no es visible en tiempo de ejecución.
Para obtener una lista con los valores de propiedadiniciales de una instancia de Timer, vea el constructor de Timer.
Ejemplo
En el siguiente ejemplo se crea un Timer que muestra "Hello World!" en la consola cada cinco segundos.
Se utiliza elespacio de nombres System.Timers para este ejemplo.
C#
C++
VB
using System;
using System.Timers;
public class Timer1{
public static void Main()
{
// Normally, the timer is declared at the class level, so
// that it doesn'tgo out of scope when the method ends.
// In this example, the timer is needed only while Main
// is executing. However, KeepAlive must be used at the// end of Main, to prevent the JIT compiler from allowing
// aggressive garbage collection to occur before Main
// ends.System.Timers.Timer aTimer = new System.Timers.Timer();
// Hook up the Elapsed event for the timer.aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
// Set the Interval to 2 seconds (2000 milliseconds).
aTimer.Interval = 2000;aTimer.Enabled = true;
Console.WriteLine("Press the Enter key to exit the program.");
Console.ReadLine();...
Regístrate para leer el documento completo.