gpt4 book ai didi

c# - 使用 C# 检索系统正常运行时间

转载 作者:IT王子 更新时间:2023-10-29 03:47:09 24 4
gpt4 key购买 nike

是否有使用 C# 获取系统正常运行时间的简单方法?

最佳答案

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());
}
}
}

关于c# - 使用 C# 检索系统正常运行时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/972105/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com