private void Initialize(bool appRunOnStartup) { bool cacheFolderCreated; _filteredCacheItems = ReadCache(appRunOnStartup, out _cacheUpToDate, out cacheFolderCreated, out _lastFullScanTime); _fileSystemChanges = new FileSystemChanges(); if (cacheFolderCreated) { string cacheFolder = GetCacheFolder(); try { FileSystemChangeEventArgs e = new FileSystemChangeEventArgs(null, cacheFolder); HandleFolderSystemChanged(this, e); } catch (PathTooLongException) { } } //Listen to the changes in the whole system to update the fullCache. //This handler should be bound just after reading the full cache to ensure that _fullCache is initialized. _fileSystemListener.FolderSystemChanged += HandleFolderSystemChanged; _fileSystemListener.StartListening(null); //Parse file system fully (asynchronously). if (!_cacheUpToDate) { StartFileSystemParsing(); } }
public void StartListening_FolderCreated_EventFired() { _fileSystemListener.StartListening(new List <string> { FolderName }); Directory.CreateDirectory(TempFolderName); Thread.Sleep(200); Assert.That(_eventArgs, Is.Not.Null); Assert.That(_eventArgs.OldFullPath, Is.Null); Assert.That(_eventArgs.NewFullPath, Is.EqualTo(Path.GetFullPath(TempFolderName))); }
private void RunListener() { _fileSystemListener.FolderSystemChanged += HandleFolderSystemChanged; _fileSystemListener.StartListening(FoldersToParse); lock (_listenerLaunchSync) { _listenerLaunched = true; } }