private async Task <TransitionResult> ViewModelOnPageTransitionRequested(object sender,
                                                                                 [NotNull] TransitionRequest transitionRequest)
        {
            if (transitionRequest == null)
            {
                throw new ArgumentNullException(nameof(transitionRequest));
            }

            var tcs = new TaskCompletionSource <TransitionResult>();
            await Invoker.InvokeAsync(async() =>
            {
                try
                {
                    if (!(sender is IStoryboardPageViewModel viewModel))
                    {
                        throw new InvalidOperationException("Incorrect request of transition");
                    }

                    var result = await GoToPageAsync(
                        transitionRequest.DestinationPageId,
                        viewModel.StoryboardId,
                        transitionRequest.DestinationPageContext)
                                 .ConfigureAwait(true);
                    tcs.SetResult(result);
                }
                catch (Exception e)
                {
                    ExceptionOccured?.Invoke(this, e);
                    tcs.SetResult(TransitionResult.Failed);
                }
            }).ConfigureAwait(false);

            return(await tcs.Task.ConfigureAwait(true));
        }
        public static Task InvokeAsync(this Func <object, TransitionRequest, Task> handler, object arg, TransitionRequest request)
        {
            if (handler == null)
            {
                return(Task.CompletedTask);
            }

            var invocationList = handler.GetInvocationList();
            var handlerTasks   = new Task[invocationList.Length];

            for (var i = 0; i < invocationList.Length; i++)
            {
                handlerTasks[i] = ((Func <object, TransitionRequest, Task>)invocationList[i])(arg, request);
            }

            return(Task.WhenAll(handlerTasks));
        }