Exemple #1
0
        /// <summary>
        ///   Execute all commands in command table and delete them
        /// </summary>
        /// <param name="res">result.</param>
        protected internal void Execute(IResultValue res)
        {
            IClientTargetedCommand cmd;
            int i, j;
            int currFrame = ClientManager.Instance.getCmdFrame(); //cmdFrame++;  save a local value of the frame

            ClientManager.Instance.add1toCmdFrame();
            int firstBlocking = -1;

            // frames are used here to make sure that when this method is called recursively
            // the inner call will not execute commands that should be executed by some outer
            // call to the method

            // First step - move all result commands before any blocking commands (QCR #693428)
            // it can't be that they belong to the blocking task.
            for (i = 0; i < getSize(); i++)
            {
                cmd = getCmd(i) as IClientTargetedCommand;

                if (cmd.IsBlocking && firstBlocking == -1)
                {
                    firstBlocking = i;
                }
                else if (cmd is ResultCommand && firstBlocking != -1)
                {
                    _cmds.Insert(firstBlocking, cmd);
                    _cmds.RemoveAt(i + 1);
                }
            }

            // set the frame for commands which has no frame yet
            for (i = 0; i < getSize(); i++)
            {
                cmd       = getCmd(i) as IClientTargetedCommand;
                cmd.Frame = currFrame;

                // If a command blocks the caller, following commands are moved to
                // the next active MGdata, so they will be executed (QCR #438387)
                if (cmd.IsBlocking)
                {
                    for (j = i + 1; j < getSize(); j++)
                    {
                        ClientManager.Instance.addUnframedCmd(getCmd(j));
                    }
                    _cmds.SetSize(i + 1);
                    break;
                }
            }

            while (getSize() > 0)
            {
                cmd = extractCmd(currFrame) as IClientTargetedCommand;
                if (cmd != null)
                {
                    if (cmd.ShouldExecute)
                    {
                        cmd.Execute(res);
                    }
                    else
                    {
                        ClientManager.Instance.addCommandsExecutedAfterTaskStarted(cmd);
                    }
                }
                else
                {
                    break;
                }
            }
        }
Exemple #2
0
 /// <summary>removes a control from the table by index.</summary>
 /// <param name = "idx">the idx of the control to be removed</param>
 public void Remove(int idx)
 {
     _controls.RemoveAt(idx);
 }