Beispiel #1
0
        private void EnableWLB()
        {
            // Enable WLB.
            EnableWLBAction action = new EnableWLBAction(_pool);

            // We will need to re-enable buttons when the action completes
            action.Completed += Program.MainWindow.action_Completed;
            action.Completed += this.action_Completed;
            action.RunAsync();
        }
        private bool EnableWlb()
        {
            // Enable WLB.
            EnableWLBAction action = new EnableWLBAction(_pool);

            // We will need to re-enable buttons when the action completes
            action.Completed += Program.MainWindow.action_Completed;
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks);

            dialog.ShowCancel = true;
            dialog.ShowDialog(this);

            Program.MainWindow.UpdateToolbars();
            return(action.Succeeded);
        }
Beispiel #3
0
        /// <summary>
        /// Finds the WLBAction in progress that pertains to the given connection, or null
        /// if there is no such action.
        /// Must be called on the event thread.
        /// </summary>
        /// <param name="connection">May not be null.</param>
        /// <returns></returns>
        internal static AsyncAction FindActiveWLBAction(IXenConnection connection)
        {
            Program.AssertOnEventThread();
            foreach (ActionBase action in ConnectionsManager.History)
            {
                if (action.IsCompleted)
                {
                    continue;
                }

                InitializeWLBAction configureAction = action as InitializeWLBAction;
                if (configureAction != null && !configureAction.Cancelled && configureAction.Connection == connection)
                {
                    return(configureAction);
                }

                EnableWLBAction enableAction = action as EnableWLBAction;
                if (enableAction != null && !enableAction.Cancelled && enableAction.Connection == connection)
                {
                    return(enableAction);
                }

                DisableWLBAction disableAction = action as DisableWLBAction;
                if (disableAction != null && !disableAction.Cancelled && disableAction.Connection == connection)
                {
                    return(disableAction);
                }

                RetrieveWlbConfigurationAction retrieveAction = action as RetrieveWlbConfigurationAction;
                if (retrieveAction != null && !retrieveAction.Cancelled && retrieveAction.Connection == connection)
                {
                    return(retrieveAction);
                }

                SendWlbConfigurationAction sendAction = action as SendWlbConfigurationAction;
                if (sendAction != null && !sendAction.Cancelled && sendAction.Connection == connection)
                {
                    return(sendAction);
                }
            }
            return(null);
        }
Beispiel #4
0
        protected void action_Completed(ActionBase sender)
        {
            // This seems to be called off the event thread
            AsyncAction action = (AsyncAction)sender;

            if (action.IsCompleted)
            {
                action.Completed -= action_Completed;
                if (action is EnableWLBAction || action is RetrieveWlbConfigurationAction || action is DisableWLBAction)
                {
                    if (action is EnableWLBAction)
                    {
                        EnableWLBAction thisAction = (EnableWLBAction)action;
                        _wlbPoolConfiguration = new WlbPoolConfiguration(thisAction.WlbConfiguration);
                    }
                    else if (action is RetrieveWlbConfigurationAction)
                    {
                        RetrieveWlbConfigurationAction thisAction = (RetrieveWlbConfigurationAction)action;
                        if (thisAction.Succeeded)
                        {
                            _wlbPoolConfiguration = new WlbPoolConfiguration(thisAction.WlbConfiguration);
                        }
                        else
                        {
                            //_statusError = thisAction.Exception.Message;
                            _wlbPoolConfiguration = null;
                        }
                    }
                    else if (action is DisableWLBAction)
                    {
                    }

                    Program.Invoke(Program.MainWindow, delegate()
                    {
                        if (_pool != null && _pool.Connection == action.Connection)
                        {
                            RefreshControls();
                        }
                    });
                }
            }
        }