public TimeSpan UpTime {
get {
using (var uptime = new PerformanceCounter("System", "System Up Time")) {
uptime.NextValue(); //Call this an extra time before reading its value
return TimeSpan.FromSeconds(uptime.NextValue());
}
}
}
More Related Contents:
- How can I register a global hot key to say CTRL+SHIFT+(LETTER) using WPF and .NET 3.5?
- Detecting USB drive insertion and removal using windows service and c#
- How can I run another application within a panel of my C# program?
- How can I run an EXE program from a Windows Service using C#?
- How to detect Windows shutdown or logoff
- Unique file identifier in windows
- .NET (C#): Getting child windows when you only have a process handle or PID?
- Is there Windows system event on active window changed?
- How do I get information about recently connected USB device?
- Winforms: Application.Exit vs Environment.Exit vs Form.Close
- How to force C# .net app to run only one instance in Windows? [duplicate]
- How to check if another instance of the application is running [duplicate]
- Log off user from Win XP programmatically in C#
- How to delete a file after checking whether it exists
- C# – Regex for file paths e.g. C:\test\test.exe
- How do I get common file type icons in C#?
- .NET FileInfo.LastWriteTime & FileInfo.LastAccessTime are wrong
- Determining if a folder is shared in .NET
- Why is infinity printed as “8” in the Windows 10 console?
- Why does Environment.Exit() not terminate the program any more?
- How do I spawn threads on different CPU cores?
- Is there a way to convert a System.IO.Stream to a Windows.Storage.Streams.IRandomAccessStream?
- OraOLEDB.Oracle provider is not registered on the local machine
- How to stop Windows service programmatically
- How do I compute the non-client window size in WPF?
- Bluetooth APIs in Windows/.Net?
- The type ‘System.IDisposable’ is defined in an assembly that is not referenced
- How do I minimize a WinForms application to the notification area?
- Defining a working directory for executing a program (C#)
- Detect if non DPI-aware application has been scaled/virtualized