Catel.MVVM.ViewModelBase.CloseViewModelAsync C# (CSharp) Method

CloseViewModelAsync() public method

Closes this instance. Always called after the Cancel of Save method.
public CloseViewModelAsync ( bool result ) : Task
result bool The result to pass to the view. This will, for example, be used as DialogResult.
return Task
        public async Task CloseViewModelAsync(bool? result)
        {
            if (IsClosed)
            {
                return;
            }

            UninitializeThrottling();

            IsClosing = true;

            await OnClosingAsync();

            ViewModelManager.UnregisterAllModels(this);

            await CloseAsync();

            SuspendValidation = true;

            // Note: important to set *before* calling the event (the handler might need to check
            // if the vm is closed)
            IsClosing = false;
            IsClosed = true;

            await OnClosedAsync(result);

            Log.Info("Closed view model '{0}'", GetType());

            ViewModelManager.UnregisterViewModelInstance(this);
        }
#endregion