Ejemplo n.º 1
0
        /// <summary>
        ///     Start searching empty folders
        /// </summary>
        public void SearchingForEmptyDirectories()
        {
            this.CurrentProcessStep = WorkflowSteps.StartSearchingForEmptyDirs;

            // Rest folder list
            this.Data.ProtectedFolderList = new Dictionary <String, Boolean>();

            this.searchEmptyFoldersWorker = new FindEmptyDirectoryWorker {
                Data = this.Data
            };

            this.searchEmptyFoldersWorker.ProgressChanged    += this.searchEmptyFoldersWorker_ProgressChanged;
            this.searchEmptyFoldersWorker.RunWorkerCompleted += this.searchEmptyFoldersWorker_RunWorkerCompleted;

            // Start worker
            this.searchEmptyFoldersWorker.RunWorkerAsync(this.Data.StartFolder);
        }
Ejemplo n.º 2
0
        private void searchEmptyFoldersWorker_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e)
        {
            this.CurrentProcessStep = WorkflowSteps.Idle;

            if (e.Error != null)
            {
                this.searchEmptyFoldersWorker.Dispose();
                this.searchEmptyFoldersWorker = null;

                this.showErrorMsg(e.Error.Message);
            }
            else if (e.Cancelled)
            {
                if (this.searchEmptyFoldersWorker.ErrorInfo != null)
                {
                    // A error occurred, process was stopped
                    this.showErrorMsg(this.searchEmptyFoldersWorker.ErrorInfo.ErrorMessage);

                    this.searchEmptyFoldersWorker.Dispose();
                    this.searchEmptyFoldersWorker = null;

                    this.OnAborted?.Invoke(this, new EventArgs());
                }
                else
                {
                    this.searchEmptyFoldersWorker.Dispose();
                    this.searchEmptyFoldersWorker = null;

                    this.OnCancelled?.Invoke(this, new EventArgs());
                }
            }
            else
            {
                var FolderCount = this.searchEmptyFoldersWorker.FolderCount;

                this.searchEmptyFoldersWorker.Dispose();
                this.searchEmptyFoldersWorker = null;

                this.OnFinishedScanForEmptyDirs?.Invoke(this, new FinishedScanForEmptyDirsEventArgs(this.Data.EmptyFolderList.Count, FolderCount));
            }
        }