public async Task StopLoading() { using (await this._lock.LockAsync()) { var currentCount = Interlocked.Decrement(ref this._loadingItems); if (currentCount == 0) { await this._progressController.CloseAsync(); this._progressController = null; this.Report(0); this._isLoading = false; this.NotifyPropertyChanged("IsLoading"); } } }
public async Task StartLoading(string title = null, bool isCancelable = false) { using (await this._lock.LockAsync()) { var currentCount = Interlocked.Increment(ref this._loadingItems); if (currentCount == 1) { var chocoDialg = new ChocolateyDialog(this.MainWindow); this._progressController = await this.MainWindow.ShowChocolateyDialogAsync(title, isCancelable); this._progressController.SetIndeterminate(); if (isCancelable) { this._cst = new CancellationTokenSource(); this._progressController.OnCanceled += dialog => { if (this._cst != null) { _cst.Cancel(); } }; } this._output.Clear(); this._isLoading = true; this.NotifyPropertyChanged("IsLoading"); } } }