Command Bar doesn't clear when I get a string

I call the GetString method, then when I successfully get a string I call a method I created. Here’s a part of code:

            if (get_rc == Rhino.Input.GetResult.String)
            {
                intervals = CustomMethod();

                doc.Views.Redraw();
                RhinoApp.WriteLine("{0} added a line to the document.", EnglishName);
            }

My custom method involves several for loops and adding lines to the screen. I call:
“EscapeKeyEventHandler handler = new EscapeKeyEventHandler(“Press to stop drawing.”);”

but the command bar then replaces “Press to stop drawing” with the original GetString. How can I stop it from asking input?

You have not provided enough information for us to be helpful. What exactly are you trying to do and why?

This my code:

   public int CustomMethod(RhinoDoc doc, Rhino.Input.Custom.GetString getStr, Expression eq, ref Rhino.Collections.Point3dList points, bool drawExpression, int degree, CurveKnotStyle knotStyle, double ll, double ul, double acc)
    {
            EscapeKeyEventHandler handler = new EscapeKeyEventHandler("Press <Esc> to stop drawing.");
  		for(int u = 0; u < 200000000; u++);

            return 1;
    }
    
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        // TODO: start here modifying the behaviour of your command.
        // ---
        
        
        RhinoApp.WriteLine("{0} will begin.", EnglishName);

        Rhino.Input.Custom.GetString getStr = new Rhino.Input.Custom.GetString();
        int intervals = 0;

        // Set up options
        getStr.EnableTransparentCommands(true);
        getStr.SetCommandPrompt("Enter String");
        getStr.SetDefaultString(null);
        getStr.AcceptNothing(true);

        while (true)
        {
            // perform the get operation. This will prompt the user to input a string, but also
            // allow for command line options defined above

            Rhino.Input.GetResult get_rc = getStr.GetLiteralString();
            if (getStr.CommandResult() != Rhino.Commands.Result.Success)
            {
                return getStr.CommandResult();
            }

            if (get_rc == Rhino.Input.GetResult.String)
            {
                intervals = CustomMethod();
            }
            else if (get_rc == Rhino.Input.GetResult.Option)
            {
                continue;
            }
            
            break;
        }
    
        return Result.Success;
    }

When I call CustomMethod, I should have already gotten a string from getStr. But while I’m in the for loop in CustomMethod, the command bar shows: “Enter String:”, and not “Press to stop loop”. I’m assuming this means that getStr doesn’t stop asking for input until the whole command is over.

I don’t know if this is related, but when I’m being prompted for a string, and I decide to quit the command by calling on another plugin command I made, rather than go directly to that command the original command just stops. I want to make it like (here’s an example) if I’m making a point, and decide to make a rectangle instead, I click the rectangle command and it automatically replaces the point command.