Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 19, 2014 01:46
Show Gist options
  • Save Fhernd/9e151d5501515786aaa7 to your computer and use it in GitHub Desktop.
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#.
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