public async Task StartLoading(string title = null, bool isCancelable = false) { using (await _lock.LockAsync()) { var currentCount = Interlocked.Increment(ref _loadingItems); if (currentCount == 1) { var chocoDialg = new ChocolateyDialog(MainWindow); _progressController = await MainWindow.ShowChocolateyDialogAsync(title, isCancelable); _progressController.SetIndeterminate(); if (isCancelable) { _cst = new CancellationTokenSource(); _progressController.OnCancelled += dialog => { if (_cst != null) { _cst.Cancel(); } }; } _output.Clear(); _isLoading = true; NotifyPropertyChanged("IsLoading"); } } }
public Task <ChocolateyDialogController> ShowChocolateyDialogAsync( string title, bool isCancelable = false, MetroDialogSettings settings = null) { return(Dispatcher.Invoke(async() => { // create the dialog control var dialog = new ChocolateyDialog(this, _configService.GetSettings().ShowConsoleOutput) { Title = title, IsCancelable = isCancelable, OutputBufferCollection = _progressService.Output }; if (settings == null) { settings = MetroDialogOptions; } dialog.NegativeButtonText = settings.NegativeButtonText; await this.ShowMetroDialogAsync(dialog); return new ChocolateyDialogController(dialog, () => this.HideMetroDialogAsync(dialog)); })); }
public Task <ChocolateyDialogController> ShowChocolateyDialogAsync(string title, bool isCancelable = false, MetroDialogSettings settings = null) { return((Task <ChocolateyDialogController>)Dispatcher.Invoke(new Func <Task <ChocolateyDialogController> >(async() => { //create the dialog control var dialog = new ChocolateyDialog(this); dialog.Title = title; dialog.IsCancelable = isCancelable; dialog.OutputBuffer = _progressService.Output; if (settings == null) { settings = MetroDialogOptions; } dialog.NegativeButtonText = settings.NegativeButtonText; await this.ShowMetroDialogAsync(dialog); return new ChocolateyDialogController(dialog, () => { return this.HideMetroDialogAsync(dialog); }); }))); }