Discuz.Common/SysInfo.cs
(开头部分) 9KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using Microsoft.Win32;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Discuz.Common
{
/// <summary>
/// SysInfo 的摘要说明。
/// </summary>
public class SysInfo
{
#region CpuUsage类
/// <summary>
/// Defines an abstract base class for implementations of CPU usage counters.
/// </summary>
public abstract class CpuUsage
{
/// <summary>
/// Creates and returns a CpuUsage instance that can be used to query the CPU time on this operating system.
/// </summary>
/// <returns>An instance of the CpuUsage class.</returns>
/// <exception cref="NotSupportedException">This platform is not supported -or- initialization of the CPUUsage object failed.</exception>
public static CpuUsage Create()
{
if (m_CpuUsage == null)
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
m_CpuUsage = new CpuUsageNt();
else if (Environment.OSVersion.Platform == PlatformID.Win32Windows)
m_CpuUsage = new CpuUsage9x();
else
throw new NotSupportedException();
}
return m_CpuUsage;
}
/// <summary>
/// Determines the current average CPU load.
/// </summary>
/// <returns>An integer that holds the CPU load percentage.</returns>
/// <exception cref="NotSupportedException">One of the system calls fails. The CPU time can not be obtained.</exception>
public abstract int Query();
/// <summary>
/// Holds an instance of the CPUUsage class.
/// </summary>
private static CpuUsage m_CpuUsage= null;
}
//------------------------------------------- win 9x ---------------------------------------
/// <summary>
/// Inherits the CPUUsage class and implements the Query method for Windows 9x systems.
/// </summary>
/// <remarks>
/// <p>This class works on Windows 98 and Windows Millenium Edition.</p>
/// <p>You should not use this class directly in your code. Use the CPUUsage.Create() method to instantiate a CPUUsage object.</p>
/// </remarks>
internal sealed class CpuUsage9x : CpuUsage
{
/// <summary>
后面还有 173 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
