Advertisement
Fhernd

UsoSleepConTimeSpan.cs

Sep 19th, 2014
716
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. namespace Recetas.Multithreading.Cap01
  5. {
  6.     public sealed class UsoSleepConTimeSpan
  7.     {
  8.         public static void Main()
  9.         {
  10.             // Creación de intervalo de tiempo con 0 horas,
  11.             // 0 minutos, y 2 segundos:
  12.             TimeSpan intervalo = new TimeSpan (0, 0, 2);
  13.            
  14.             for (int i = 0; i < 5; ++i)
  15.             {
  16.                 Console.WriteLine ("Pausando durante 2 segundos...");
  17.                 // Pausa el Thread actual durante 2 segundos:
  18.                 Thread.Sleep (intervalo);
  19.             }
  20.            
  21.             Console.WriteLine ("El método Main ha finalizado.");
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement