get data from div(js) using c# winforms - c#

here is a part of HTML where contains JS
<script type="text/javascript" src="/scripts/left-menu.js"></script>
This is part of code that displays at some time:
<div id="bx"></div>
And this is left-menu.js
var v = new Date();
var sec_raznica = c * 1000 - v.getTime();
var greenwich = ((v.getTimezoneOffset() * 60 * -1) - (120 * 60)) * -1000;
function t() {
var time = new Date();
time = Math.floor(time.getTime());
var t = new Date(time + sec_raznica + greenwich);
var date1 = t.getDate();
var date2 = t.getMonth() + 1;
var time1 = t.getHours();
var time2 = t.getMinutes();
var time3 = t.getSeconds();
if (date1 < 10) date1 = "0" + date1;
if (date2 < 10) date2 = "0" + date2;
if (time1 < 10) time1 = "0" + time1;
if (time2 < 10) time2 = "0" + time2;
if (time3 < 10) time3 = "0" + time3;
document.getElementById("bx").innerHTML = date1 + "." + date2 + " " + time1 + ":" + time2 + ":" + time3;
window.setTimeout("t();", 1000);
}
window.onload = t;
How do I get this data from div with id="bx" without using webBrowser?

Related

ASP.NET MVC : accesing object properties

I'm converting my code for specific models to a generic (all models will be accepted) version so I'm converting my label border but I can't access data in model because of I was accessing them like this:
worksheet.Cells["A" + index].Value = temp[i - 2].CarID.ToString();
but now I converted this access to something like this:
worksheet.Cells[L + index].Value = temp[i - 2].names[j].ToString();
but it's not working. I understand first one accesses object values but second one tries to access different one so how can I access this object values? I'm past full code for this function can you give me some idea about this situation? Thanks for help
public void EEPCreateExcelGeneric(ReportRange reportRange)
{
using (ExcelPackage excel = new ExcelPackage())
{
// var temp = db.Database.SqlQuery<CarsTrxViewModel>(SqlCars.CarsTrxByID()).ToList();
var temp = db.Cars.ToList();
Cars cars = new Cars();
// var properties = temp.GetType().GetProperties();
var names = new List<string>();
var properties = cars.GetType().GetProperties();
foreach (var item in properties)
{
var attribute = (DisplayNameAttribute)item.GetCustomAttribute(typeof(DisplayNameAttribute), true);
if (attribute != null)
{
names.Add(attribute.DisplayName);
}
else
{
names.Add(item.Name);
}
}
// System.Diagnostics.Debug.WriteLine(properties);
DateTime startdate = reportRange.StartDate;// ?? new DateTime(2000, 10, 10, 1, 1, 1, 1);
DateTime enddate = reportRange.EndDate;// ?? DateTime.Now;
DateTime now = DateTime.Now;
string date = now.ToShortDateString();
string time = now.ToLongTimeString();
date = date + "-" + time;
// modeli çekerken db de temizlersek çok daha hızlı olur
foreach (var item in temp.ToList())
{
if (item.CreateDate < startdate || item.CreateDate > enddate)
{
temp.Remove(item);
}
}
int RowRange = temp.Count();
string name = "Report_";
date = date.Replace(" ", "_");
date = date.Replace(",", "_");
date = date.Replace(":", "-");
date = date.Replace("/", "_");
string sonu = ".xls";
date += sonu;
name += date;
ExcelRecords m = new ExcelRecords();
m.IsExist = false;
m.CreateDate = now;
m.EndDate = enddate;
m.StartDate = startdate;
m.GuidName = name;
db.ExcelRecords.Add(m);
db.SaveChanges();
excel.Workbook.Worksheets.Add("Worksheet1");
var worksheet = excel.Workbook.Worksheets["worksheet1"];
//worksheet.Cells["A1"].Value = "CarID";
//worksheet.Cells["B1"].Value = "CarBrand";
//worksheet.Cells["C1"].Value = "CarModel";
//worksheet.Cells["D1"].Value = "CreateDate";
//worksheet.Cells["A1"].Style.Font.Bold = true;
//worksheet.Cells["B1"].Style.Font.Bold = true;
//worksheet.Cells["C1"].Style.Font.Bold = true;
//worksheet.Cells["D1"].Style.Font.Bold = true;
for (int i = 0; i < names.Count(); i++)
{
string L = (Convert.ToChar(65+i)).ToString();
L += "1";
System.Diagnostics.Debug.WriteLine(L);
worksheet.Cells[L].Value = names[i];
worksheet.Cells[L].Style.Font.Bold = true;
}
for (int i = 2; i < (RowRange + 2); i++)
{
/*
string L = (Convert.ToChar(63 + i)).ToString();
string index = i.ToString();
worksheet.Cells[L + index].Value = temp[i - 2].CarID.ToString();
worksheet.Cells[L + index].Value = temp[i - 2].CarBrand.ToString();
worksheet.Cells[L + index].Value = temp[i - 2].CarModel.ToString();
worksheet.Cells[L + index].Value = temp[i - 2].CreateDate.ToString();
*/
string index = i.ToString();
for (int j = 0; j < names.Count; j++)
{
string L = (Convert.ToChar(65 + j)).ToString();
worksheet.Cells[L + index].Value = temp[i - 2].names[j].ToString();//<=
// its not working what is right way for doing this
}
worksheet.Cells["A" + index].Value = temp[i - 2].CarID.ToString();
worksheet.Cells["B" + index].Value = temp[i - 2].CarBrand.ToString();
worksheet.Cells["C" + index].Value = temp[i - 2].CarModel.ToString();
worksheet.Cells["D" + index].Value = temp[i - 2].CreateDate.ToString();
}
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
string path = Path.Combine(Server.MapPath("~/"), ("Reports\\" + name));
FileInfo excelFile = new FileInfo(path);
excel.SaveAs(excelFile);
var bull = db.ExcelRecords.SingleOrDefault(b => b.GuidName == name);
if (bull != null)
{
bull.IsExist = true;
db.SaveChanges();
}
}
}

Get Dates lists between 2 dates C#

how i can get dates ranges list between 2 dates
for example,
start date is 12 February
end date is 23 May
so, the result must be like
12-Feb to 28-Feb
1-Mar to 31-Mar
1-April to 30-April
1-May to 23-May
Let's suppose you are checking only one year, i.e. the current one (2018).
Of course you can make StartDate and EndDate parametric.
There's nothing special in the code below; I used "d-MMMM" as date format since you seemed to ask for the minimum number of days ("d" does that, i.e. selects 1 and not 01 for the first day of a month) and the "long" name of the month ("MMMM" does that, check this answer).
If instead you just want the abbreviation, i.e. "Feb" for "February", you can use "MMM" (check this other answer).
DateTime StartDate = new DateTime(2018, 2, 12);
DateTime EndDate = new DateTime(2018, 5, 23);
for (int i = 0; i <= EndDate.Month - StartDate.Month; i++)
{
DateTime FirstDay = new DateTime(2018, StartDate.Month + i, 1);
if (i == 0)
{
FirstDay = StartDate;
}
DateTime LastDay = new DateTime(2018, StartDate.Month + i, DateTime.DaysInMonth(2018, FirstDay.Month));
if (i == EndDate.Month - StartDate.Month)
{
LastDay = EndDate;
}
Console.WriteLine(FirstDay.ToString("d-MMMM") + " to " + LastDay.ToString("d-MMMM"));
}
Console.ReadLine();
You can also use the following code to make it "cross-year":
static void Main(string[] args)
{
PrintDateList(new DateTime(2018, 2, 12), new DateTime(2018, 5, 23));
PrintDateList(new DateTime(2018, 11, 12), new DateTime(2019, 2, 23));
Console.ReadLine();
}
private static void PrintDateList(DateTime StartDate, DateTime EndDate)
{
Console.WriteLine("");
int TotalMonths = EndDate.Month - StartDate.Month +
(EndDate.Year - StartDate.Year) * 12;
int CurrentYear = StartDate.Year;
int MonthsToSubtract = 0;
for (int i = 0; i <= TotalMonths; i++)
{
int CurrentMonth = StartDate.Month + i;
if (StartDate.Month + i > 12)
{
if ((StartDate.Month + i) % 12 == 1)
{
CurrentYear++;
Console.WriteLine(CurrentYear.ToString());
MonthsToSubtract = StartDate.Month + i - 1;
}
CurrentMonth = StartDate.Month + i - MonthsToSubtract;
}
DateTime FirstDay = new DateTime(CurrentYear, CurrentMonth, 1);
if (i == 0)
{
FirstDay = StartDate;
}
DateTime LastDay = new DateTime(CurrentYear, CurrentMonth, DateTime.DaysInMonth(CurrentYear, FirstDay.Month));
if (i == TotalMonths)
{
LastDay = EndDate;
}
Console.WriteLine(FirstDay.ToString("d-MMMM") + " to " + LastDay.ToString("d-MMMM"));
}
}
The output is
12-February to 28-February
1-March to 31-March
1-April to 30-April
1-May to 23-May
12-November to 30-November
1-December to 31-December
1-January to 31-January
1-February to 23-February
Since you asked, I replaced Console.WriteLine with a List:
private static void PrintDateList(DateTime StartDate, DateTime EndDate)
{
List<Tuple<DateTime>> EventsDatesRangeList = new List<Tuple<DateTime>>();
Console.WriteLine("");
int TotalMonths = EndDate.Month - StartDate.Month +
(EndDate.Year - StartDate.Year) * 12;
int CurrentYear = StartDate.Year;
int MonthsToSubtract = 0;
for (int i = 0; i <= TotalMonths; i++)
{
int CurrentMonth = StartDate.Month + i;
if (StartDate.Month + i > 12)
{
if ((StartDate.Month + i) % 12 == 1)
{
CurrentYear++;
Console.WriteLine(CurrentYear.ToString());
MonthsToSubtract = StartDate.Month + i - 1;
}
CurrentMonth = StartDate.Month + i - MonthsToSubtract;
}
DateTime FirstDay = new DateTime(CurrentYear, CurrentMonth, 1);
if (i == 0)
{
FirstDay = StartDate;
}
DateTime LastDay = new DateTime(CurrentYear, CurrentMonth, DateTime.DaysInMonth(CurrentYear, FirstDay.Month));
if (i == TotalMonths)
{
LastDay = EndDate;
}
Console.WriteLine(FirstDay.ToString("d-MMMM") + " to " + LastDay.ToString("d-MMMM"));
EventsDatesRangeList.Add(new Tuple<DateTime>(FirstDay));
EventsDatesRangeList.Add(new Tuple<DateTime>(LastDay));
}
}

Timing in Ticket System

I have nearly finished a project I've been working on for over three months. This is my first program I've ever made, so it may not be the cleanest code but for the most part works. The only issue I'm having now is getting the times to line up between specific times (In this instance 8am and 3pm). I am getting times outside of these times instead of inside. My current code is
if (DateTime.Now.AddMinutes(timetoadd).Hour < 8)
{
MessageBox.Show("Too early_Button Pressed");
var now = DateTime.Now;
var today8am = now.AddDays(0).Date.AddHours(8);
double totalHours = (today8am - now).TotalHours;
MessageBox.Show("totalHours=" + totalHours);
double hourstoadd = 0;// = timetoadd / 60;
MessageBox.Show("TTA = " + timetoadd.ToString());
do
{
hourstoadd++;
if (DateTime.Now.AddHours(hourstoadd).Hour == 15)
{
hourstoadd = hourstoadd + 17;
}
timetoadd = timetoadd - 60;
System.Diagnostics.Debug.WriteLine(hourstoadd.ToString());
}
while (timetoadd >= 60);
MessageBox.Show("TTA2 = " + timetoadd.ToString());
do
{
hourstoadd = hourstoadd - 8;
daystoadd++;
if (DateTime.Now.DayOfWeek.ToString() == "Saturday")
{
daystoadd = daystoadd + 2;
}
else if (DateTime.Now.DayOfWeek.ToString() == "Sunday")
{
daystoadd = daystoadd + 1;
}
}
while (hourstoadd > 8);
if (DateTime.Now.AddDays(daystoadd).AddHours(hourstoadd).Date.AddHours(hourstoadd + now.Hour).AddMinutes(timetoadd + now.Minute).DayOfWeek.ToString() == "Saturday")
{
daystoadd = daystoadd + 2;
}
else if (DateTime.Now.AddDays(daystoadd).AddHours(hourstoadd).Date.AddHours(hourstoadd + now.Hour).AddMinutes(timetoadd + now.Minute).DayOfWeek.ToString() == "Sunday")
{
daystoadd = daystoadd + 1;
}
EstimatedCompleteDate = DateTime.Now.AddDays(daystoadd).AddHours(hourstoadd).Date.AddHours(hourstoadd + now.Hour).AddMinutes(timetoadd + now.Minute).ToString();
MessageBox.Show("ETA = " + EstimatedCompleteDate);
}
else if (DateTime.Now.AddMinutes(timetoadd).Hour > 15)
{
MessageBox.Show("Too Late_Button Pressed");
var now = DateTime.Now;
var tomorrow8am = now.AddDays(1).Date.AddHours(8);
double totalHours = (tomorrow8am - now).TotalHours;
MessageBox.Show("totalHours=" + totalHours);
double hourstoadd = 0;// = timetoadd / 60;
MessageBox.Show("TTA = " + timetoadd.ToString());
do
{
hourstoadd++;
if (DateTime.Now.AddHours(hourstoadd).Hour == 15)
{
hourstoadd = hourstoadd + 17;
}
timetoadd = timetoadd - 60;
System.Diagnostics.Debug.WriteLine(hourstoadd.ToString());
}
while (timetoadd >= 60);
MessageBox.Show("TTA2 = " + timetoadd.ToString());
do
{
hourstoadd = hourstoadd - 8;
daystoadd++;
if (DateTime.Now.DayOfWeek.ToString() == "Saturday")
{
daystoadd = daystoadd + 2;
}
else if (DateTime.Now.DayOfWeek.ToString() == "Sunday")
{
daystoadd = daystoadd + 1;
}
}
while (hourstoadd > 8);
if (DateTime.Now.AddDays(daystoadd).AddHours(hourstoadd).Date.AddHours(hourstoadd + now.Hour).AddMinutes(timetoadd + now.Minute).DayOfWeek.ToString() == "Saturday")
{
daystoadd = daystoadd + 2;
}
else if (DateTime.Now.AddDays(daystoadd).AddHours(hourstoadd).Date.AddHours(hourstoadd + now.Hour).AddMinutes(timetoadd + now.Minute).DayOfWeek.ToString() == "Sunday")
{
daystoadd = daystoadd + 1;
}
EstimatedCompleteDate = DateTime.Now.AddDays(daystoadd).AddHours(hourstoadd).Date.AddHours(hourstoadd + now.Hour).AddMinutes(timetoadd + now.Minute).ToString();
MessageBox.Show("ETA = " + EstimatedCompleteDate);
}
else if (DateTime.Now.AddMinutes(timetoadd).Hour <= 15 && DateTime.Now.AddMinutes(timetoadd).Hour >= 8)
{
MessageBox.Show("Regular hours");
var now = DateTime.Now;
var tomorrow8am = now.AddDays(1).Date.AddHours(8);
double totalHours = 0;
MessageBox.Show("totalHours=" + totalHours);
double hourstoadd = 0 + now.Minute;// = timetoadd / 60;
MessageBox.Show("TTA = " + timetoadd.ToString());
do
{
hourstoadd++;
if (DateTime.Now.AddHours(hourstoadd).Hour == 15)
{
hourstoadd = hourstoadd + 17;
}
timetoadd = timetoadd - 60;
System.Diagnostics.Debug.WriteLine(hourstoadd.ToString());
}
while (timetoadd >= 60);
MessageBox.Show("TTA2 = " + timetoadd.ToString());
do
{
hourstoadd = hourstoadd - 8;
daystoadd++;
if (DateTime.Now.DayOfWeek.ToString() == "Saturday")
{
daystoadd = daystoadd + 2;
}
else if (DateTime.Now.DayOfWeek.ToString() == "Sunday")
{
daystoadd = daystoadd + 1;
}
}
while (hourstoadd > 8);
if (DateTime.Now.AddDays(daystoadd).AddHours(hourstoadd).Date.AddHours(hourstoadd + now.Hour).AddMinutes(timetoadd + now.Minute).DayOfWeek.ToString() == "Saturday")
{
daystoadd = daystoadd + 2;
}
else if (DateTime.Now.AddDays(daystoadd).AddHours(hourstoadd).Date.AddHours(hourstoadd + now.Hour).AddMinutes(timetoadd + now.Minute).DayOfWeek.ToString() == "Sunday")
{
daystoadd = daystoadd + 1;
}
EstimatedCompleteDate = DateTime.Now.AddDays(daystoadd).AddHours(hourstoadd).Date.AddHours(hourstoadd + now.Hour).AddMinutes(timetoadd + now.Minute).ToString();
MessageBox.Show("ETA = " + EstimatedCompleteDate);
}
timetoadd = sum + current_ticket_time in minutes.
sum = all previous ticket times.
I am using Messagebox's to provide me a form of immediate feedback.
The other night I was able to get a script that works for exactly what's needed.
var soonh = 0;
var now = DateTime.Now;
var soonm = 0;
double minutestoadd = timetoadd;
int hourstoadd = 0;
if (minutestoadd >= 60)
{
do
{
minutestoadd = minutestoadd - 60;
hourstoadd++;
}
while (minutestoadd > 60);
}
soonh = 6 - (Convert.ToInt32(now.Hour));
soonm = 60 - ((Convert.ToInt32(now.Minute)));
if (soonm < 0)
{
var temp = soonm;
soonm = 0;
soonh = soonh - 1;
soonm = 60 + temp;
Console.WriteLine("Sample");
}
double totalmin = soonm + now.Minute + minutestoadd;
if (totalmin >= 60)
{
do
{
if (totalmin >= 60)
{
totalmin = totalmin - 60;
hourstoadd = hourstoadd + 1;
}
}
while (totalmin >= 60);
if (soonh < 0)
{
soonh = 0;
}
int totalhour = soonh + now.Hour + hourstoadd;
int totalday = 0;
bool sample = false;
do
{
if (totalhour >= 8)
{
totalhour = totalhour - 7;
totalday = totalday + 1;
sample = true;
}
}
while (totalhour >= 8);
if (sample == true)
{
totalday = totalday - 1;
}
totalhour = totalhour + 7;
if (totalhour + DateTime.Today.Hour >= 15)
{
totalhour = totalhour - 7;
}
if (DateTime.Today.Date.AddDays(totalday) == DateTime.Today)
{
totalday++;
}
EstimatedCompleteDate = (DateTime.Today.Date.AddDays(totalday).AddHours(totalhour).AddMinutes(totalmin).ToString());
}

Implementing a string based calendar in C#

I want to create a C# program that displays a calendar and uses a string that contains the names of the days:
string Names = "Sun,Mon,Tues,Wed,Thurs,Fri,Sat,";
So far I have....
int weeks = 1;
int days = 1;
string Names = "Sun,Mon,Tues,Wed,Thurs,Fri,Sat,";
string dayName;
int commaIndex = 0;
int date = 1;
while (weeks < 5)
{
while (days < 8)
{
commaIndex = Names.IndexOf(","); // find the period
dayName = Names.Remove(commaIndex);
lblCalendar.Text += dayName + "." + " " + date + " ";
Names = Names.Remove(0, commaIndex + 1);
days++;
date++;
}
weeks++;
}
But that only writes the first week.. can anybody help me figure out where there is an error?
First, you forgot to restart days variable after every iteration.
Also, after first iteration your Names string is empty.
I suggest to create array of day names and use it instead of one string.
int weeks = 1;
int days = 1;
var Names = new[] {"Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat" };
string dayName;
int commaIndex = 0;
int date = 1;
while (weeks < 5)
{
while (days < 8)
{
dayName = Names[days-1];
lblCalendar.Text += dayName + "." + " " + date + " ";
days++;
date++;
}
days = 1;
weeks++;
}
You forgot to reset days.
while (weeks < 5)
{
days = 1
string Names = "Sun,Mon,Tues,Wed,Thurs,Fri,Sat,";
while (days < 8)
{

.net for loop performance issue

I have this code :
namespace FrequencyGeneratorConsoleApplication
{
class Program
{
static void Main(string[] args)
{
Thread.CurrentThread.Priority = ThreadPriority.Highest;
int from = 100000;// Convert.ToInt32(txtFrom.Text);
int to = 999999;//Convert.ToInt32(txtTo.Text);
int numbers = 2000; //Convert.ToInt32(txtNumbers.Text);
int range = 50;// Convert.ToInt32(txtRange.Text);
var generatedFrequencies = new List<Frequency>(to - from);
var availableRanges = new List<AvailableRange>(to - from + 1);
//AvailableRange maxAvailableRange = new AvailableRange();
var random = new Random();
DateTime first = DateTime.Now;
for (int i = 0; i < numbers; i++)
{
var frequency = new Frequency();
if (availableRanges.Count == 0)
{
frequency.Number = random.Next(from, to);
frequency.Number = (int)Math.Round((decimal)frequency.Number / 5) * 5;
int fromValue = frequency.Number - (range / 2);
int toValue = frequency.Number + (range / 2);
frequency.From = fromValue < from ? from : fromValue;
frequency.To = toValue > to ? to : toValue;
generatedFrequencies.Add(frequency);
var availableRange1 = new AvailableRange { From = #from, To = frequency.From };
availableRange1.RangeLong = availableRange1.To - availableRange1.From;
availableRanges.Add(availableRange1);
var availableRange2 = new AvailableRange { From = frequency.To, To = to };
availableRange2.RangeLong = availableRange2.To - availableRange2.From;
availableRanges.Add(availableRange2);
}
else
{
DateTime d1 = DateTime.Now;
int max = 0, index = 0;
for (int j = 0; j < availableRanges.Count; j++)
{
if (availableRanges[j].RangeLong > range)
{
index = j;
}
}
DateTime d2 = DateTime.Now;
double total1 = (d2 - d1).TotalMilliseconds;
AvailableRange availableRange = availableRanges[index];
if (availableRange.RangeLong <= range)
{
Console.WriteLine("there is no available pathes " + generatedFrequencies.Count);
break;
}
DateTime d3 = DateTime.Now;
double total2 = (d3 - d2).TotalMilliseconds;
frequency.Number = random.Next(availableRange.From + (range / 2), availableRange.To - (range / 2));
frequency.Number = (int)Math.Round((decimal)frequency.Number / 5) * 5;
int fromValue = frequency.Number - (range / 2);
int toValue = frequency.Number + (range / 2);
frequency.From = fromValue < from ? from : fromValue;
frequency.To = toValue > to ? to : toValue;
generatedFrequencies.Add(frequency);
var availableRange1 = new AvailableRange { From = availableRange.From, To = frequency.From, RangeLong = frequency.From - availableRange.From };
availableRanges.Add(availableRange1);
//availableRange.From = 1;
var availableRange2 = new AvailableRange { From = frequency.To, To = availableRange.To, RangeLong = availableRange.To - frequency.To };
availableRanges.Add(availableRange2);
//availableRange.To = frequency.From;
//availableRange.RangeLong = availableRange.To - availableRange.From;
DateTime d4 = DateTime.Now;
double total3 = (d4 - d3).TotalMilliseconds;
//availableRange.RangeLong = 0;
availableRanges.RemoveAt(index);
DateTime d5 = DateTime.Now;
double total4 = (d5 - d4).TotalMilliseconds;
double total = (d5 - d1).TotalMilliseconds;
if (total > 1)
{
// Console.WriteLine(total + #" : " + total1 + #" : " + total2 + #" : " + total3 + #" : " + total4 +
// #" frequency : " + frequency.Number + #" max : " + max + #" index : " + index);
}
}
}
DateTime last = DateTime.Now;
Console.WriteLine((last - first));
Console.ReadLine();
}
}
public class Frequency
{
public int From { get; set; }
public int To { get; set; }
public int Number { get; set; }
public override string ToString()
{
return " from : " + From + " to : " + To + " number : " + Number;
}
}
public class AvailableRange
{
public int From { get; set; }
public int To { get; set; }
public int RangeLong { get; set; }
public override string ToString()
{
return " from : " + From + " to : " + To + " RangeLong : " + RangeLong;
}
}
}
now the problem is this code take some time
when i analyze the code i expect that some cycles take 15 milliseconds and others take 0 millisecond
if the number of loops is small this problem does not appear
i tried to solve this problem but i could not find the answered
what is the problem
Not use DateTime for performance measure. Use System.Diagnostics.Stopwatch
What you are seeing is the 16 millisecond accuracy limitation of the System.DateTime structure.
See http://blogs.msdn.com/b/ericlippert/archive/2010/04/08/precision-and-accuracy-of-datetime.aspx.
You need to use the System.Diagnostics.Stopwatch class instead for any sort of performance assessment as it is usually accurate to the microsecond (depending on how much thread context switching is occurring at the time of the test).
I think that you cannot get an accurate measurement because this is a user-mode code running in multitasking environment. Even if the thread priority is set to highest, it can be superseded by any kernel mode process.

Categories

Resources