Advertisement
Fhernd

EjecucionTareaProgramada.cs

Jun 24th, 2014
2,222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. namespace Recetas.Cap04
  5. {
  6.     public sealed class EjecucionTareaProgramada
  7.     {
  8.         public static void Main()
  9.         {
  10.             // Crea intervalo de tiempo de 10 segundos:
  11.             TimeSpan tiempoEspera = new TimeSpan (0, 0, 10);
  12.            
  13.             // Crea un temporizador que se iniciará 10 segundos
  14.             // después de creada una instancia de Timer. Y
  15.             // sólo se ejecutará una vez:
  16.             new Timer (
  17.                 delegate (object obj)
  18.                 {
  19.                     Console.WriteLine ("\nEl temporizador se inició a las {0}",
  20.                                        DateTime.Now.ToString ("HH:mm:ss.ffff"));
  21.                 },
  22.                 null, tiempoEspera, new TimeSpan(-1)
  23.             );
  24.            
  25.             Console.Write ("\nA espera de finalización del temporizador.");
  26.             Console.WriteLine (" Presione Enter para finalizar.");
  27.             Console.ReadLine();
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement