Files
ThreadPilot/Models/ProcessModel.cs
T
Focaccina-Ripiena37 ea350bf7fd Add core mask management and remove Game Boost features
Introduces a new core mask system for managing CPU affinity, including models, services, and Windows platform handlers. Adds a dedicated Core Masks tab and related views/viewmodels. Removes all Game Boost related code, settings, and UI. Updates process association models to support core masks and process priority. Improves graceful shutdown to clear masks and restore power plans. Refines affinity display and default settings for better usability.
2025-12-21 03:27:41 +01:00

83 lines
2.5 KiB
C#

using System;
using System.Diagnostics;
using CommunityToolkit.Mvvm.ComponentModel;
namespace ThreadPilot.Models
{
public partial class ProcessModel : ObservableObject
{
private Process? _process;
public Process? Process
{
get => _process;
set
{
_process = value;
if (value != null)
{
ProcessId = value.Id;
Name = value.ProcessName;
try
{
ProcessorAffinity = (long)value.ProcessorAffinity;
Priority = value.PriorityClass;
MemoryUsage = value.PrivateMemorySize64;
ExecutablePath = value.MainModule?.FileName ?? string.Empty;
MainWindowHandle = value.MainWindowHandle;
MainWindowTitle = value.MainWindowTitle ?? string.Empty;
HasVisibleWindow = MainWindowHandle != IntPtr.Zero && !string.IsNullOrWhiteSpace(MainWindowTitle);
}
catch (Exception)
{
// Process may have terminated or access denied
}
}
}
}
[ObservableProperty]
private int processId;
[ObservableProperty]
private string name = string.Empty;
[ObservableProperty]
private string executablePath = string.Empty;
[ObservableProperty]
private double cpuUsage;
[ObservableProperty]
private long memoryUsage;
[ObservableProperty]
private ProcessPriorityClass priority;
[ObservableProperty]
private long processorAffinity;
[ObservableProperty]
private IntPtr mainWindowHandle;
[ObservableProperty]
private string mainWindowTitle = string.Empty;
[ObservableProperty]
private bool hasVisibleWindow;
[ObservableProperty]
private bool isIdleServerDisabled;
[ObservableProperty]
private bool isRegistryPriorityEnabled;
/// <summary>
/// Forces PropertyChanged notification for ProcessorAffinity.
/// Used to update DataGrid binding when affinity changes from background thread.
/// </summary>
public void ForceNotifyProcessorAffinityChanged()
{
OnPropertyChanged(nameof(ProcessorAffinity));
}
}
}