由网友(寄 泩 蟲╮)分享简介:有没有一种简单的方法,使用C#来获取系统的正常运行时间?解决方案 公开时间跨度正常运行时间{得到 {使用(VAR运行时间=新的PerformanceCounter(系统,系统运行时间)){uptime.NextValue(); //读取它的值之前调用此额外的时间返回TimeSpan.FromSeconds(upti...![电脑修复中出现oxc0000142是什么原因](https://p.xsw88.cn/allimgs/daicuo/20230902/639.png)
有没有一种简单的方法,使用C#来获取系统的正常运行时间?
解决方案 公开时间跨度正常运行时间{
得到 {
使用(VAR运行时间=新的PerformanceCounter(系统,系统运行时间)){
uptime.NextValue(); //读取它的值之前调用此额外的时间
返回TimeSpan.FromSeconds(uptime.NextValue());
}
}
}
Is there a simple way to get a system's uptime using C#?
解决方案![电脑修复中出现oxc0000142是什么原因](https://p.xsw88.cn/allimgs/daicuo/20230902/639.png)
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());
}
}
}
相关推荐
最新文章