Click here to Skip to main content
15,914,642 members
Home / Discussions / C#
   

C#

 
AnswerRe: CAD system design Pin
Alan Balkany21-Mar-12 4:54
Alan Balkany21-Mar-12 4:54 
Questioni have a global mouse hook working but.. Pin
gmes2919-Mar-12 14:07
gmes2919-Mar-12 14:07 
AnswerRe: i have a global mouse hook working but.. Pin
Dave Kreskowiak19-Mar-12 16:08
mveDave Kreskowiak19-Mar-12 16:08 
GeneralRe: i have a global mouse hook working but.. Pin
gmes2920-Mar-12 0:59
gmes2920-Mar-12 0:59 
Questionsame enumeration, different results? Pin
CCodeNewbie19-Mar-12 12:15
CCodeNewbie19-Mar-12 12:15 
AnswerRe: same enumeration, different results? Pin
PIEBALDconsult19-Mar-12 12:31
mvePIEBALDconsult19-Mar-12 12:31 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie19-Mar-12 12:39
CCodeNewbie19-Mar-12 12:39 
GeneralRe: same enumeration, different results? Pin
PIEBALDconsult19-Mar-12 12:43
mvePIEBALDconsult19-Mar-12 12:43 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie19-Mar-12 12:50
CCodeNewbie19-Mar-12 12:50 
GeneralRe: same enumeration, different results? Pin
PIEBALDconsult19-Mar-12 13:20
mvePIEBALDconsult19-Mar-12 13:20 
AnswerRe: same enumeration, different results? Pin
Luc Pattyn19-Mar-12 14:56
sitebuilderLuc Pattyn19-Mar-12 14:56 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 0:48
CCodeNewbie20-Mar-12 0:48 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 0:48
CCodeNewbie20-Mar-12 0:48 
GeneralRe: same enumeration, different results? Pin
PIEBALDconsult20-Mar-12 3:34
mvePIEBALDconsult20-Mar-12 3:34 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 8:29
CCodeNewbie20-Mar-12 8:29 
GeneralRe: same enumeration, different results? Pin
PIEBALDconsult20-Mar-12 11:03
mvePIEBALDconsult20-Mar-12 11:03 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 12:08
CCodeNewbie20-Mar-12 12:08 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 2:30
CCodeNewbie20-Mar-12 2:30 
GeneralRe: same enumeration, different results? Pin
Alan N20-Mar-12 3:39
Alan N20-Mar-12 3:39 
I'm glad you've come to a solution that you are happy with. One point that I'm not sure you appreciate is that the up time obtained from the performance counter and the TickCount are essentially the same value.

C#
private void CompareCounterAndTickCount() {
  using (PerformanceCounter ut = new PerformanceCounter("System", "System Up Time")) {
    ut.NextValue();
    TimeSpan counterUpTime = TimeSpan.FromSeconds(ut.NextValue());
    TimeSpan tickCountUpTime = TimeSpan.FromMilliseconds(Environment.TickCount);
    Console.WriteLine("Up Time");
    Console.WriteLine("  from performance counter {0}", counterUpTime);
    Console.WriteLine("  from tickcount           {0}", tickCountUpTime);
  }
}


On my system the duration reported by TickCount is ~0.2s longer than the performance counter's value which presumably just means the two counters do not share the same origin. Also note the use of the FromMilliseconds method to convert the TickCount to a TimeSpan, much simpler than your multistep calculation!

Alan.
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 8:33
CCodeNewbie20-Mar-12 8:33 
GeneralRe: same enumeration, different results? Pin
Alan N20-Mar-12 10:47
Alan N20-Mar-12 10:47 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 12:00
CCodeNewbie20-Mar-12 12:00 
AnswerWrongMagicConstantInHorribleCodeException Pin
Luc Pattyn19-Mar-12 13:03
sitebuilderLuc Pattyn19-Mar-12 13:03 
GeneralRe: WrongMagicConstantInHorribleCodeException Pin
CCodeNewbie19-Mar-12 13:05
CCodeNewbie19-Mar-12 13:05 
GeneralRe: WrongMagicConstantInHorribleCodeException Pin
CCodeNewbie19-Mar-12 13:08
CCodeNewbie19-Mar-12 13:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.