Created
June 25, 2014 04:25
-
-
Save Fhernd/14a4402a6da02385baf3 to your computer and use it in GitHub Desktop.
Demostración de uso del constructor Timer(TimerCallback, Object, TimeSpan, TimeSpan) en C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
namespace Recetas.Cap04 | |
{ | |
public sealed class EjecucionTareaProgramada | |
{ | |
public static void Main() | |
{ | |
// Crea intervalo de tiempo de 10 segundos: | |
TimeSpan tiempoEspera = new TimeSpan (0, 0, 10); | |
// Crea un temporizador que se iniciará 10 segundos | |
// después de creada una instancia de Timer. Y | |
// sólo se ejecutará una vez: | |
new Timer ( | |
delegate (object obj) | |
{ | |
Console.WriteLine ("\nEl temporizador se inició a las {0}", | |
DateTime.Now.ToString ("HH:mm:ss.ffff")); | |
}, | |
null, tiempoEspera, new TimeSpan(-1) | |
); | |
Console.Write ("\nA espera de finalización del temporizador."); | |
Console.WriteLine (" Presione Enter para finalizar."); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment