Ejemplo n.º 1
0
            public async Task <TResult> Invoke <TCommand, TResult>(object sender, TCommand command, CancellationToken cancellationToken = default, IProgress <ProgressData> progress = null) where TCommand : UiCommand <TResult>
            {
                IBusyContext busyContext = null;

                if (this.busyManager != null)
                {
                    busyContext = this.busyManager.Begin(this.operationType);
                }

                IProgress <ProgressData> innerProgress = new ProxyProgressReporter(progress, busyContext);

                try
                {
                    return(await this.decorated.Invoke <TCommand, TResult>(sender, command, cancellationToken, innerProgress).ConfigureAwait(false));
                }
                catch (OperationCanceledException e)
                {
                    Logger.Warn(e.Message, e);
                    return(default);
Ejemplo n.º 2
0
            public async Task Invoke <TCommand>(object sender, TCommand command, CancellationToken cancellationToken = default, IProgress <ProgressData> progress = null) where TCommand : UiCommand
            {
                IBusyContext busyContext = null;

                if (this.busyManager != null)
                {
                    busyContext = this.busyManager.Begin(this.operationType);
                }

                IProgress <ProgressData> innerProgress = new ProxyProgressReporter(progress, busyContext);

                try
                {
                    await this.decorated.Invoke(sender, command, cancellationToken, innerProgress).ConfigureAwait(false);
                }
                catch (OperationCanceledException e)
                {
                    Logger.Warn(e.Message, e);
                }
                catch (Exception e)
                {
                    Logger.Error(e.Message, e);
                    if (this.interactionService != null)
                    {
                        if (this.ShowError(e) == InteractionResult.Retry)
                        {
                            Logger.Info("The user wanted to retry...");
                            await this.Invoke(sender, command, cancellationToken, innerProgress).ConfigureAwait(false);
                        }
                    }
                }
                finally
                {
                    if (busyContext != null)
                    {
                        this.busyManager.End(busyContext);
                    }
                }
            }