using System; using System.Threading.Tasks; using ThreadPilot.Models; namespace ThreadPilot.Services { /// /// Interface for process monitoring service that uses WMI events with fallback polling /// public interface IProcessMonitorService : IDisposable { /// /// Event fired when a process starts /// event EventHandler? ProcessStarted; /// /// Event fired when a process stops /// event EventHandler? ProcessStopped; /// /// Event fired when monitoring status changes /// event EventHandler? MonitoringStatusChanged; /// /// Gets whether the service is currently monitoring /// bool IsMonitoring { get; } /// /// Gets whether WMI monitoring is available and working /// bool IsWmiAvailable { get; } /// /// Gets whether fallback polling is currently active /// bool IsFallbackPollingActive { get; } /// /// Starts monitoring processes /// Task StartMonitoringAsync(); /// /// Stops monitoring processes /// Task StopMonitoringAsync(); /// /// Gets all currently running processes /// Task> GetRunningProcessesAsync(); /// /// Checks if a specific process is currently running /// Task IsProcessRunningAsync(string executableName); /// /// Updates the service settings (polling intervals, etc.) /// void UpdateSettings(); } /// /// Event arguments for process events /// public class ProcessEventArgs : EventArgs { public ProcessModel Process { get; } public DateTime Timestamp { get; } public ProcessEventArgs(ProcessModel process) { Process = process; Timestamp = DateTime.Now; } } /// /// Event arguments for monitoring status changes /// 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 MonitoringStatusEventArgs(bool isMonitoring, bool isWmiAvailable, bool isFallbackPollingActive, string? statusMessage = null, Exception? error = null) { IsMonitoring = isMonitoring; IsWmiAvailable = isWmiAvailable; IsFallbackPollingActive = isFallbackPollingActive; StatusMessage = statusMessage; Error = error; } } }