Exemplo n.º 1
0
        private void DirScanButton_Click(object sender, RoutedEventArgs e)
        {
            if (_scanInProgress == false)
            {
                DirCount  = 0;
                FileCount = 0;
                CurrentFileLabel.Content     = null;
                CurrentFileSizeLabel.Content = null;
                CurrentFileSizeLabel.Content = null;
                TotalFilesLabel.Content      = null;
                TotalTimeLabel.Content       = null;

                DataModel.Clear();

                _dbEngine.DeleteTable(@"FileDB");
                _dbEngine.CreateTable(DBQueries.FileTableCreateQuery);

                start = DateTime.Now;
                workerThread.RunWorkerAsync();
                DirScanButton.Content = "Stop Scan";
                _scanInProgress       = true;
            }
            else
            {
                if (_dirEnum != null)
                {
                    _dirEnum.StopEnumeration();
                }

                DirScanButton.Content = "Begin Scan";

                // Disable the button here because if App is scanning a big file in the middle
                // we have to wait for it to finish and cannot terminate the thread right away.
                // If we dont disable this, user can click the begin scan again and this causes
                // crash. When we stop the scan, workerThread_RunWorkerCompleted will be called and
                // and we enable the button again.
                DirScanButton.IsEnabled = false;
            }
        }