Ejemplo n.º 1
0
 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)
     {
     }
 }
Ejemplo n.º 2
0
 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)
     {
     }
 }