/*
* 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.Collections.Generic;
using System.Threading.Tasks;
using ThreadPilot.Models;
namespace ThreadPilot.Services
{
///
/// Configuration for virtualized process loading
///
public class VirtualizedProcessConfig
{
public int BatchSize { get; set; } = 50;
public int PreloadBatches { get; set; } = 2;
public bool EnableBackgroundLoading { get; set; } = true;
public TimeSpan RefreshInterval { get; set; } = TimeSpan.FromSeconds(5);
}
///
/// Result of a batch loading operation
///
public class ProcessBatchResult
{
public List Processes { get; set; } = new();
public int BatchIndex { get; set; }
public int TotalBatches { get; set; }
public int TotalProcessCount { get; set; }
public bool HasMoreBatches { get; set; }
public TimeSpan LoadTime { get; set; }
}
///
/// Event arguments for batch loading progress
///
public class BatchLoadProgressEventArgs : EventArgs
{
public int LoadedBatches { get; set; }
public int TotalBatches { get; set; }
public int LoadedProcesses { get; set; }
public int TotalProcesses { get; set; }
public double ProgressPercentage => TotalBatches > 0 ? (double)LoadedBatches / TotalBatches * 100 : 0;
public string StatusMessage { get; set; } = string.Empty;
}
///
/// Service for virtualized process loading with batch support
///
public interface IVirtualizedProcessService
{
///
/// Configuration for virtualized loading
///
VirtualizedProcessConfig Configuration { get; set; }
///
/// Initialize the virtualized process service
///
Task InitializeAsync();
///
/// Get the total number of processes available
///
Task GetTotalProcessCountAsync(bool activeApplicationsOnly = false);
///
/// Load a specific batch of processes
///
Task LoadProcessBatchAsync(int batchIndex, bool activeApplicationsOnly = false);
///
/// Load multiple batches starting from a specific index
///
Task> LoadProcessBatchesAsync(int startBatchIndex, int batchCount, bool activeApplicationsOnly = false);
///
/// Preload the next batch in background
///
Task PreloadNextBatchAsync(int currentBatchIndex, bool activeApplicationsOnly = false);
///
/// Search processes across all batches
///
Task> SearchProcessesAsync(string searchTerm, bool activeApplicationsOnly = false);
///
/// Refresh a specific batch
///
Task RefreshBatchAsync(int batchIndex, bool activeApplicationsOnly = false);
///
/// Clear all cached batches
///
void ClearCache();
///
/// Event raised when batch loading progress changes
///
event EventHandler? BatchLoadProgress;
///
/// Event raised when background preloading completes
///
event EventHandler? BackgroundBatchLoaded;
}
}