public Win32ProgramRepository(IList <IFileSystemWatcherWrapper> fileSystemWatcherHelpers, IStorage <IList <Win32Program> > storage, ProgramPluginSettings settings, string[] pathsToWatch) { _fileSystemWatcherHelpers = fileSystemWatcherHelpers; _storage = storage ?? throw new ArgumentNullException(nameof(storage), "Win32ProgramRepository requires an initialized storage interface"); _settings = settings ?? throw new ArgumentNullException(nameof(settings), "Win32ProgramRepository requires an initialized settings object"); _pathsToWatch = pathsToWatch; _numberOfPathsToWatch = pathsToWatch.Length; InitializeFileSystemWatchers(); // This task would always run in the background trying to dequeue file paths from the queue at regular intervals. _ = Task.Run(async() => { while (true) { int dequeueDelay = 500; string appPath = await EventHandler.GetAppPathFromQueueAsync(commonEventHandlingQueue, dequeueDelay).ConfigureAwait(false); // To allow for the installation process to finish. await Task.Delay(5000).ConfigureAwait(false); if (!string.IsNullOrEmpty(appPath)) { Programs.Win32Program app = Programs.Win32Program.GetAppFromPath(appPath); if (app != null) { Add(app); } } } }).ConfigureAwait(false); }
public Win32ProgramRepository(IList <IFileSystemWatcherWrapper> fileSystemWatcherHelpers, IStorage <IList <Win32Program> > storage, ProgramPluginSettings settings, string[] pathsToWatch) { _fileSystemWatcherHelpers = fileSystemWatcherHelpers; _storage = storage ?? throw new ArgumentNullException(nameof(storage), "Win32ProgramRepository requires an initialized storage interface"); _settings = settings ?? throw new ArgumentNullException(nameof(settings), "Win32ProgramRepository requires an initialized settings object"); _pathsToWatch = pathsToWatch; _numberOfPathsToWatch = pathsToWatch.Length; InitializeFileSystemWatchers(); }