Files
ThreadPilot/Services/IProcessMonitorService.cs
Prime Build 03872a39b8 fix: recover saved-rule monitoring after sleep (v1.7.9) (#96)
Renew WMI subscriptions after resume, unlock, watcher failure or prolonged silence, then rescan processes and reapply saved rules. Retry unavailable executable paths, initialize diagnostics before monitoring, and use the shared startup path. Include regression tests and v1.7.9 release metadata. Related to #95; keep open pending reporter confirmation.
2026-11-11 15:11:56 +01:00

71 lines
1.9 KiB
C#

namespace ThreadPilot.Services
{
using System;
using System.Threading.Tasks;
using ThreadPilot.Models;
public interface IProcessMonitorService : IDisposable
{
event EventHandler<ProcessEventArgs>? ProcessStarted;
event EventHandler<ProcessEventArgs>? ProcessStopped;
event EventHandler<MonitoringStatusEventArgs>? MonitoringStatusChanged;
bool IsMonitoring { get; }
bool IsWmiAvailable { get; }
bool IsFallbackPollingActive { get; }
Task StartMonitoringAsync();
Task StopMonitoringAsync();
Task<IEnumerable<ProcessModel>> GetRunningProcessesAsync();
Task<bool> IsProcessRunningAsync(string executableName);
void UpdateSettings();
}
public class ProcessEventArgs : EventArgs
{
public ProcessModel Process { get; }
public DateTime Timestamp { get; }
public ProcessEventArgs(ProcessModel process)
{
this.Process = process;
this.Timestamp = DateTime.Now;
}
}
public class MonitoringStatusEventArgs : EventArgs
{
public bool IsMonitoring { get; }
public bool IsWmiAvailable { get; }
public bool IsFallbackPollingActive { get; }
public string? StatusMessage { get; }
public Exception? Error { get; }
public bool SnapshotRefreshed { get; }
public MonitoringStatusEventArgs(bool isMonitoring, bool isWmiAvailable, bool isFallbackPollingActive, string? statusMessage = null, Exception? error = null, bool snapshotRefreshed = false)
{
this.IsMonitoring = isMonitoring;
this.IsWmiAvailable = isWmiAvailable;
this.IsFallbackPollingActive = isFallbackPollingActive;
this.StatusMessage = statusMessage;
this.Error = error;
this.SnapshotRefreshed = snapshotRefreshed;
}
}
}