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." ) ;
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uVGhyZWFkaW5nOwoKbmFtZXNwYWNlIFJlY2V0YXMuTXVsdGl0aHJlYWRpbmcuQ2FwMDEKewogICAgcHVibGljIHNlYWxlZCBjbGFzcyBVc29TbGVlcENvblRpbWVTcGFuCiAgICB7CiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQogICAgICAgIHsKICAgICAgICAgICAgLy8gQ3JlYWNpw7NuIGRlIGludGVydmFsbyBkZSB0aWVtcG8gY29uIDAgaG9yYXMsIAogICAgICAgICAgICAvLyAwIG1pbnV0b3MsIHkgMiBzZWd1bmRvczoKICAgICAgICAgICAgVGltZVNwYW4gaW50ZXJ2YWxvID0gbmV3IFRpbWVTcGFuICgwLCAwLCAyKTsKICAgICAgICAgICAgCiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgNTsgKytpKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSAoIlBhdXNhbmRvIGR1cmFudGUgMiBzZWd1bmRvcy4uLiIpOwogICAgICAgICAgICAgICAgLy8gUGF1c2EgZWwgVGhyZWFkIGFjdHVhbCBkdXJhbnRlIDIgc2VndW5kb3M6CiAgICAgICAgICAgICAgICBUaHJlYWQuU2xlZXAgKGludGVydmFsbyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgCiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lICgiRWwgbcOpdG9kbyBNYWluIGhhIGZpbmFsaXphZG8uIik7CiAgICAgICAgfQogICAgfQp9