Created
June 19, 2014 01:46
-
-
Save Fhernd/9e151d5501515786aaa7 to your computer and use it in GitHub Desktop.
Demostración de TimeSpan como argumento para el método Thread.Sleep. 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.Multithreading.Cap01 | |
{ | |
public sealed class UsoSleepConTimeSpan | |
{ | |
public static void Main() | |
{ | |
// Creación de intervalo de tiempo con 0 horas, | |
// 0 minutos, y 2 segundos: | |
TimeSpan intervalo = new TimeSpan (0, 0, 2); | |
for (int i = 0; i < 5; ++i) | |
{ | |
Console.WriteLine ("Pausando durante 2 segundos..."); | |
// Pausa el Thread actual durante 2 segundos: | |
Thread.Sleep (intervalo); | |
} | |
Console.WriteLine ("El método Main ha finalizado."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment