private void ContinousScan() { try { while (true) { _tokenSource.Token.WaitHandle.WaitOne(5000); _tokenSource.Token.ThrowIfCancellationRequested(); var groups = new Queue <FileGroup>(); groups.Enqueue(this); while (groups.Count > 0) { _tokenSource.Token.ThrowIfCancellationRequested(); groups.AddAll(groups.Dequeue().ScanDirectories(_tokenSource.Token)); } } } catch (OperationCanceledException) { } }
private void ScanData() { try { while (true) { _tokenSource.Token.WaitHandle.WaitOne(5000); _tokenSource.Token.ThrowIfCancellationRequested(); var groups = new Queue <FileGroup>(); groups.Enqueue(this); while (groups.Count > 0) { _tokenSource.Token.ThrowIfCancellationRequested(); var fileGroup = groups.Dequeue(); foreach (var pictureFile in fileGroup.GetFiles()) { _tokenSource.Token.ThrowIfCancellationRequested(); if (!pictureFile.HasInternalDataTask()) { var task = new Task <PictureFileData>(delegate { var pictureFileData = new PictureFileData(pictureFile.FileInfo); pictureFileData.UnloadImage(); return(pictureFileData); }); task.RunSynchronously(); task.Wait(_tokenSource.Token); pictureFile.SetInternalDataTaskIfNotSet(task); } } groups.AddAll(fileGroup.GetGroups()); } } } catch (OperationCanceledException) { } }