public async Task StartLoading(string title = null, bool isCancelable = false) { using (await _lock.EnterAsync()) { var currentCount = Interlocked.Increment(ref _loadingItems); if (currentCount == 1) { await RunOnUIAsync(async() => { _progressController = await ShellView.ShowChocolateyDialogAsync(title, isCancelable); _progressController.SetIndeterminate(); if (isCancelable) { _cst = new CancellationTokenSource(); _progressController.OnCanceled += dialog => { if (_cst != null) { _cst.Cancel(); } }; } Output.Clear(); IsLoading = true; 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"); } } }
public async Task StopLoading() { using (await _lock.EnterAsync()) { var currentCount = Interlocked.Decrement(ref _loadingItems); if (currentCount == 0) { await RunOnUIAsync(() => _progressController.CloseAsync()); _progressController = null; Report(0); IsLoading = false; NotifyPropertyChanged("IsLoading"); } } }
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"); } } }