// OrtizOL - xCSw - http://o...content-available-to-author-only...t.com
using System;
using System.Diagnostics;
using System.Threading;
namespace Receta.CSharp.R0303
{
public class UsoStopwatch
{
public static void Main()
{
Console.WriteLine(Environment.NewLine);
Stopwatch sw = new Stopwatch();
// Inicia el cronómetro:
sw.Start();
// Simula la ejecución durante 10':
Thread.Sleep(10000);
// Detiene el cronómetro:
sw.Stop();
// Obtiene el tiempo transcurrido:
TimeSpan ts = sw.Elapsed;
// Formato de la representación del tiempo
// transcurrido:
string formatoTiempo = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
Console.WriteLine("Tiempo cronometrizado: {0}", formatoTiempo);
Console.WriteLine(Environment.NewLine);
}
}
}
Ly8gT3J0aXpPTCAtIHhDU3cgLSBodHRwOi8vby4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4udC5jb20KIAp1c2luZyBTeXN0ZW07CnVzaW5nIFN5c3RlbS5EaWFnbm9zdGljczsKdXNpbmcgU3lzdGVtLlRocmVhZGluZzsKIApuYW1lc3BhY2UgUmVjZXRhLkNTaGFycC5SMDMwMwp7CiAgICBwdWJsaWMgY2xhc3MgVXNvU3RvcHdhdGNoCiAgICB7CiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQogICAgICAgIHsKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoRW52aXJvbm1lbnQuTmV3TGluZSk7CiAgICAgICAgICAgIAogICAgICAgICAgICBTdG9wd2F0Y2ggc3cgPSBuZXcgU3RvcHdhdGNoKCk7CiAgICAgICAgICAgIAogICAgICAgICAgICAvLyBJbmljaWEgZWwgY3JvbsOzbWV0cm86CiAgICAgICAgICAgIHN3LlN0YXJ0KCk7CiAgICAgICAgICAgIAogICAgICAgICAgICAvLyBTaW11bGEgbGEgZWplY3VjacOzbiBkdXJhbnRlIDEwJzoKICAgICAgICAgICAgVGhyZWFkLlNsZWVwKDEwMDAwKTsKICAgICAgICAgICAgCiAgICAgICAgICAgIC8vIERldGllbmUgZWwgY3JvbsOzbWV0cm86CiAgICAgICAgICAgIHN3LlN0b3AoKTsKICAgICAgICAgICAgCiAgICAgICAgICAgIC8vIE9idGllbmUgZWwgdGllbXBvIHRyYW5zY3VycmlkbzoKICAgICAgICAgICAgVGltZVNwYW4gdHMgPSBzdy5FbGFwc2VkOwogICAgICAgICAgICAKICAgICAgICAgICAgLy8gRm9ybWF0byBkZSBsYSByZXByZXNlbnRhY2nDs24gZGVsIHRpZW1wbyAKICAgICAgICAgICAgLy8gdHJhbnNjdXJyaWRvOgogICAgICAgICAgICBzdHJpbmcgZm9ybWF0b1RpZW1wbyA9IFN0cmluZy5Gb3JtYXQoInswOjAwfTp7MTowMH06ezI6MDB9LnszOjAwfSIsIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cy5Ib3VycywgdHMuTWludXRlcywgdHMuU2Vjb25kcywgdHMuTWlsbGlzZWNvbmRzIC8gMTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlRpZW1wbyBjcm9ub21ldHJpemFkbzogezB9IiwgZm9ybWF0b1RpZW1wbyk7CiAgICAgICAgICAgIAogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZShFbnZpcm9ubWVudC5OZXdMaW5lKTsKICAgICAgICB9CiAgICB9Cn0=