mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-07 07:46:12 +02:00
Improve startup performance of CpuMonitorPlugin
This commit is contained in:
@@ -11,13 +11,17 @@ namespace DesktopMagic.BuiltInWindowElements;
|
|||||||
|
|
||||||
internal class CpuMonitorPlugin : Plugin
|
internal class CpuMonitorPlugin : Plugin
|
||||||
{
|
{
|
||||||
private readonly PerformanceCounter cpuCounter = new PerformanceCounter("Processor Information", "% Processor Utility", "_Total");
|
|
||||||
|
|
||||||
[Setting("usage-circle", "Show pie")]
|
[Setting("usage-circle", "Show pie")]
|
||||||
private readonly CheckBox usageCircleCheckBox = new CheckBox(false);
|
private readonly CheckBox usageCircleCheckBox = new CheckBox(false);
|
||||||
|
|
||||||
|
private PerformanceCounter cpuCounter = null!;
|
||||||
public override int UpdateInterval => 1000;
|
public override int UpdateInterval => 1000;
|
||||||
|
|
||||||
|
public override void Start()
|
||||||
|
{
|
||||||
|
cpuCounter = new PerformanceCounter("Processor Information", "% Processor Utility", "_Total");
|
||||||
|
}
|
||||||
|
|
||||||
public override Bitmap Main()
|
public override Bitmap Main()
|
||||||
{
|
{
|
||||||
float cpuUsage = cpuCounter.NextValue();
|
float cpuUsage = cpuCounter.NextValue();
|
||||||
|
|||||||
Reference in New Issue
Block a user