AccelStepper ConstantSpeed Example

In the ConstantSpeed example, how can you stop/cancel stepper.runSpeed() so that the program can continue with other lines inside the loop? I'm planning to put the stepper.runSpeed() inside a while loop.

// ConstantSpeed.pde
// -*- mode: C++ -*-
//
// Shows how to run AccelStepper in the simplest,
// fixed speed mode with no accelerations
/// \author  Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2009 Mike McCauley
// $Id: ConstantSpeed.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $
#include <AccelStepper.h>
AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
void setup()
{  
   stepper.setMaxSpeed(1000);
   stepper.setSpeed(50);        
}
void loop()
{  
   stepper.runSpeed();
}

The while loop would look like this:

while (number <90)
  {
    stepper.runSpeed();
    
  }

The while loop would look like this:

I hope not, as that is an infinite loop.

how can you stop/cancel stepper.runSpeed() so that the program can continue with other lines inside the loop?

The runSpeed() method makes the stepper step, if a step is needed and it is time, based on the speed and when the last step occurred.

If there are no more steps needed, runSpeed() does nothing. So, either make the required position equal the current position, or quit calling runSpeed().