Geeks With Blogs
Geeks with Blogs, the #1 blog community for IT Pros
Start Your Blog
Login
Nouman "Enz3" Zakir
17 Posts
| 41 Comments
Software professional with 6 years of industry experience in software analysis, design and development.
My Most Popular Posts
ReadOnly TextBox value in AJAX Calendar Extender on postback ASP.NET
4 comments |
1688 views
ReadOnly TextBox value in AJAX Calendar Extender on postback ASP.NET
4 comments |
3 views
ReadOnly TextBox value in AJAX Calendar Extender on postback ASP.NET
4 comments |
2 views
ReadOnly TextBox value in AJAX Calendar Extender on postback ASP.NET
4 comments |
1 views
My Other Recent Posts
Very useful windows run commands
Find text in SQL stored procedures
Launch browser to display HTML contents
Log uncaught application exceptions
Performance counter without overflow
Save Configuration Settings in Registry
Hello world!
News
Announcements
Post Categories
SQL
Windows
Funny
News
Programming
C#
.Net
ASP.NET
Archives
February 2013 (1)
March 2010 (3)
August 2009 (2)
February 2009 (7)
January 2009 (4)
Nouman Zakir
while (true) { Post.NewArticle(); }
<< Save Configuration Settings in Registry
|
Home
|
Log uncaught application exceptions >>
Performance counter without overflow
Comments (2)
|
Share
Environment.TickCount returns a 32-bit signed integer containing the amount of time in milliseconds that has passed since the last time the computer was started. But this value can overflow for systems that stay up for days at a time. To avoid this overflow problem, you can query the "System Up Time" performance counter:
public TimeSpan SystemUpTime()
{
PerformanceCounter upTime = new PerformanceCounter("System", "System Up Time");
// You've got to call this twice. First time it returns 0 and the second time it returns the real info.
upTime.NextValue();
return TimeSpan.FromSeconds(upTime.NextValue());
}
You need proper privileges to query performance counter.
Posted on Sunday, January 18, 2009 6:13 AM |
Back to top
Comments on this post: Performance counter without overflow
#
re: Performance counter without overflow
This only returns the uptime since last boot OR system resume. You need to dig deeper to find the 'real' original start-up time.
Jim
Left by
Jim
on Feb 25, 2009 4:01 PM
Your comment:
Title:
Name:
Email: (never displayed)
(will show your
gravatar
)
Website:
Comment:
Allowed tags: blockquote, a, strong, em, p, u, strike, super, sub, code
Enter the code shown above
Copyright © Nouman Zakir | Powered by:
GeeksWithBlogs.net
|
Join free
Popular Posts on Geeks with Blogs
0
Use the NotMapped Attribute with Entity Framework in Partial Classes
I Finished My First 5k Run
Integration between Resource and Message Based Architectures
Which kind of API service provider are you?
.NET Security Part 3
Geeks With Blogs Content Categories
ASP.Net
SQL Server
Apple
Google
SharePoint
Windows
Visual Studio
Team Foundation Server
Agile
Office
Design Patterns
Web
Azure
Brand New Posts on Geeks with Blogs
0
Why I Chose WordPress Over Geeks With Blogs, And Moving From WordPress.com To A GoDaddy Hosted Solution
Exploiting the Non-Uniqueness of Guids
APress Deal of the Day 17/May/2013 - Pro HTML5 with Visual Studio 2012
I was surfing io13 and found this interesting article from google
Powershell functions to get an xml node, and get and set an xml element’s value, even when the element does not already exist