I will give the top of the method code since the whole code is long and is not needed in this case.
static int tickCountLength = 1000;
int[] tickCounts = new int[tickCountLength];
int numberOfTicks = 0;
TimeSpan dtn;
void DoCaptureRenderTarget(Device device, string hook)
{
//Environment.TickCount-->array
tickCounts[numberOfTicks] = Environment.TickCount;
numberOfTicks++;
DateTime start1 = DateTime.Now;
DateTime end1 = DateTime.Now;
this.DebugMessage("Capture Time Testing " + (end1 - start1).ToString());
dtn = end1 - start1;
if (dtn.Seconds > 0)
{
string fffff = "fgf";
}
if (numberOfTicks >= tickCountLength)
{
StreamWriter w = new StreamWriter(@"c:\Milliseconds\TickCount.txt", true);
foreach (int tick in tickCounts)
{
w.WriteLine("TickCount === > " + tick.ToString());
}
w.Close();
numberOfTicks = 0;
}
The method is called each time every 1ms or 20ms not sure the real time. So i added this part trying to calculate:
DateTime start1 = DateTime.Now;
DateTime end1 = DateTime.Now;
this.DebugMessage("Capture Time Testing " + (end1 - start1).ToString());
dtn = end1 - start1;
if (dtn.Seconds > 0)
{
string fffff = "fgf";
}
But this is wrong for sure the time between end1 and start1 is 00:00:00:00 How can i calculate by milliseconds the time the methos icalling each time ?
Maybe : Using DateTime.Now.Millisecond each time and manually subtracting from the previous one (by looking at it) ? Not sure how to do it.