how to set the timer in c# [closed]
i am drawing numerous lines in screen . i need to put timer and draw the lines in panel one by one in c# using directx
Well, I'm stabbing in the dark here because of the lack of information given, but if you're just asking for a way to time something, C# has the StopWatch
class found in System.Diagnostics
, it measures time in tenths of milliseconds
Usage Example:
using System.Diagnostics
public static void TestStopWatch()
{
StopWatch sw = new StopWatch();
int temp = 0;
int repetitions = 1000000;
sw.Reset();
for (int i=0; i<repetitions; i++)
temp++;
long time = sw.Peek();
Console.WriteLine("Time = " + time/10.0 + " milliseconds.");
}
Example Output:
2.7 milliseconds
精彩评论