Пример #1
0
        private static void DeleteFiles(IEnumerable <Redistributables> redistributables, ProgressBar progressBar,
                                        DialogSession dialogSession)
        {
            Task.Factory.StartNew(() =>
            {
                var failures = new List <string>();

                foreach (var item in redistributables.Select((red, idx) => new { red, idx }))
                {
                    progressBar.Dispatcher.BeginInvoke(new Action(() => progressBar.Value = item.idx));
                    try
                    {
                        if (File.Exists(item.red.Path))
                        {
                            File.Delete(item.red.Path);
                        }
                    }
                    catch
                    {
                        failures.Add(item.red.Path);
                    }
                }

                if (failures.Count > 0)
                {
                    progressBar.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        var failuresDialog = new FailuresDialog {
                            FailuresListBox = { ItemsSource = failures }
                        };
                        dialogSession.UpdateContent(failuresDialog);
                    }));
                }
                else
                {
                    progressBar.Dispatcher.BeginInvoke(new Action(dialogSession.Close));
                }
            });
        }
Пример #2
0
        private async void StartCleaning(ProgressBar progressBar, DialogSession session)
        {
            var callback =
                new Progress <int>(
                    i => { progressBar.Dispatcher.BeginInvoke(new Action(() => { progressBar.Value = i; })); });
            var result = await cleanerService.CleanAsync(currentResult, callback);

            if (result.Failures.Count > 0)
            {
                await progressBar.Dispatcher.BeginInvoke(new Action(() =>
                {
                    var failuresDialog = new FailuresDialog {
                        FailuresListBox = { ItemsSource = result.Failures }
                    };
                    session.UpdateContent(failuresDialog);
                }));
            }
            else
            {
                await progressBar.Dispatcher.BeginInvoke(new Action(session.Close));
            }
            CanRefresh = true;
            await RunRefresh();
        }
 public void updateShow(Exception ex, DialogSession session)
 {
     InitalMessage(ex);
     view = new ErrorDialog();
     session.UpdateContent(view);
 }