Interaction logic for ProgressView.xaml
Inheritance: System.Windows.Controls.UserControl
Esempio n. 1
0
        ProgressView StartInstallation(IInstallerFactory installerFactory)
        {
            var ctSource = new CancellationTokenSource();
            var p        = new ProgressView();

            installerFactory
            .Start(p.Progress, p.UpdateCommand, ctSource.Token)
            .ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    if (t.Exception?.InnerException is OperationCanceledException)
                    {
                        Exit();
                        return;
                    }

                    Dispatcher.Invoke(() =>
                    {
                        InnerContent = new ErrorView(_logPath, Exit);
                    });
                }
                else
                {
                    Exit();
                }
            });

            p.OnCancel += (o, eventArgs) => ctSource.Cancel();

            return(p);
        }
        ProgressView StartInstallation(IInstallerFactory installerFactory)
        {            
            var ctSource = new CancellationTokenSource();
            var p = new ProgressView();
            installerFactory
                .Start(p.Progress, p.UpdateCommand, ctSource.Token)
                .ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        if (t.Exception?.InnerException is OperationCanceledException)
                        {
                            Exit();
                            return;
                        }

                        Dispatcher.Invoke(() =>
                        {
                            InnerContent = new ErrorView(_logPath, Exit);
                        });
                    }
                    else
                    {
                        Exit();
                    }
                });
            
            p.OnCancel += (o, eventArgs) => ctSource.Cancel();

            return p;
        }