Example #1
0
        private void DriveRefreshing_OnStop(UcDriveRefresh sender)
        {
            var workerCount = Interlocked.Decrement(ref this.mWorkerCount);

            if (0 == workerCount)
            {
                this.StopDriveRefreshing();
            }
        }
Example #2
0
        private void StartDriveRefreshing()
        {
            this.mWorkerCount = 0;
            var selectedItems = this.DriveList.SelectedItems;

            if (null == selectedItems)
            {
                return;
            }

            var workerCount = selectedItems.Count;

            if (0 == workerCount)
            {
                return;
            }

            //this.BtnStart.Text = "Stop";
            this.BtnStart.Enabled = false;

            this.DriveList.Enabled           = false;
            this.BtnRefreshDriveList.Enabled = false;
            this.timer1.Enabled = true;

            var checkFileTime = this.ChkCheckFileTime.Checked;
            var fileYearsOld  = (int)this.NmudFileYear.Value;

            this.mWorkerCount = workerCount;
            this.PnlWorkProgress.SuspendLayout();
            this.PnlWorkProgress.Controls.Clear();
            foreach (ListViewItem li in selectedItems)
            {
                var rootPath = li.Text;
                var title    = "[Drive ";
                title += rootPath.Substring(0, 1);
                title += "] ";
                title += li.SubItems[1].Text;

                var uc = new UcDriveRefresh();
                uc.Dock     = DockStyle.Top;
                uc.Title    = title;
                uc.RootPath = rootPath;
                if (checkFileTime)
                {
                    uc.FileYearsOld = fileYearsOld;
                }
                uc.OnStop += this.DriveRefreshing_OnStop;
                uc.Start();

                this.PnlWorkProgress.Controls.Add(uc);
            }
            this.PnlWorkProgress.ResumeLayout();
        }