private async Task Start() { this.CurrentCancellationTokenSource?.Cancel(); this.CurrentCancellationTokenSource = new CancellationTokenSource(); var engine = new SweepEngine(this.PathTextBox.Text); var items = engine.GetDiskItems(); this.TheList.ItemsSource = items; this.TheList.SelectedItem = null; await Task.WhenAll(items.Select(item => item.Start(this.CurrentCancellationTokenSource.Token))); }
private void ReportChanges(SweepEngine engine) { (this.Size, this.SizeOnDisk, this.FilesCount, this.FoldersCount) = engine.Result; this.NotifyPropertyChanged(nameof(this.Size)); this.NotifyPropertyChanged(nameof(this.SizeString)); this.NotifyPropertyChanged(nameof(this.SizeOnDisk)); this.NotifyPropertyChanged(nameof(this.SizeOnDiskString)); this.NotifyPropertyChanged(nameof(this.FilesCount)); this.NotifyPropertyChanged(nameof(this.FoldersCount)); this.NotifyPropertyChanged(nameof(this.Highlight)); }
public async Task Start(CancellationToken cancellationToken) { if (this.Type == DiskItemType.File) { return; } var engine = new SweepEngine(this.DirInfo); engine.ReportProgress += (sender, e) => this.ReportChanges(engine); await Task.Run(() => engine .CalculateDirectorySizeRecursivelyWithUpdateAsync(this.DirInfo, cancellationToken)); this.IsCalculationDone = true; this.ReportChanges(engine); }