Esempio n. 1
0
        private void CompleteClose()
        {
            INavigationContext context = CreateCloseContext();

            OnClosed(_closeParameter, context);

            bool?result          = null;
            var  operationResult = ViewModel as IHasOperationResult;

            if (operationResult != null)
            {
                result = operationResult.OperationResult;
            }
            OperationCallbackManager.SetResult(ViewModel,
                                               OperationResult.CreateResult(OperationType.WindowNavigation, ViewModel, result, context));

            _closeParameter = null;
            _shouldClose    = false;
            _isOpen         = false;
            TView view = View;

            if (view == null)
            {
                return;
            }
            ThreadManager.InvokeOnUiThreadAsync(() =>
            {
                CleanupView(view);
                _viewManager
                .CleanupViewAsync(ViewModel)
                .WithTaskExceptionHandler(ViewModel);
            });
            View = null;
        }
Esempio n. 2
0
 /// <summary>
 ///     Tries to close view-model.
 /// </summary>
 /// <param name="parameter">The specified parameter, if any.</param>
 /// <returns>An instance of task with result.</returns>
 public Task <bool> CloseAsync(object parameter)
 {
     if (!IsOpen)
     {
         throw ExceptionManager.WindowClosed();
     }
     IsClosing       = true;
     _closeParameter = parameter;
     return(OnClosing(parameter)
            .TryExecuteSynchronously(task =>
     {
         try
         {
             if (task.Result)
             {
                 CloseViewImmediate();
             }
             return task.Result;
         }
         catch (Exception e)
         {
             OperationCallbackManager.SetResult(ViewModel,
                                                OperationResult.CreateErrorResult <bool?>(OperationType.WindowNavigation, ViewModel, e,
                                                                                          CreateCloseContext()));
             throw;
         }
         finally
         {
             IsClosing = false;
         }
     }));
 }