Total members 11894 |It is currently Fri Nov 22, 2024 12:55 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Stop watch and timer and alarm, using the Stopwatch class in C#, useful in cases to measure how long your program takes to run:
csharp code
using System;
using System.Diagnostics;
using System.Threading;

class Program
{
static void Main()
{
// Creating an instance of Stopwatch
Stopwatch myWatch = new Stopwatch();

// Start counting
myWatch.Start();

// Any thing that take time
for (int i = 0; i < 200; i++)
{
// Sleep
Thread.Sleep(1);
}

// Stop the watch
myWatch.Stop();

// Write result
Console.WriteLine("Your program took :time elapsed: {0}",
myWatch.Elapsed);
}
}


You can also restart the stop watch using "restart function" :
csharp code
using System;
using System.Diagnostics;
using System.Threading;

class Program
{
static void Main()
{
Stopwatch myWatch = Stopwatch.StartNew();
// Sleep for five seconds
Thread.Sleep(5000);
// Restart the time counter
stop.Restart();
// Sleep again
Thread.Sleep(2000);
// The time difference should be 2 seconds only.
Console.WriteLine(stop.ElapsedMilliseconds);
}
}




_________________
Please recommend my post if you found it helpful


Author:
Newbie
User avatar Posts: 9
Have thanks: 0 time

can you reupload plzzzzz


Author:
Newbie
User avatar Posts: 5
Have thanks: 0 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : stop watch
 Stop animation in JQuery     -  
 Poseidon Infosoft: One Stop Solution for all your IT needs.     -  
 Poseidon Infosoft: One Stop Solution for all your IT needs.     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com