/* * ThreadPilot - Advanced Windows Process and Power Plan Manager * Copyright (C) 2025 Prime Build * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 only. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ 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; } } }