HEDL encoders with Stepper motors

Hi all, Am trying to write a code that can read the positions of a stepper motor while the stepper motor is also rotating. I want to read the positions from the serial monitor....I can move the stepper using the L298 circuit and arduino mega and also read the positions but using two codes. But i want this to happen simultaneously. Thank you very much for the help.

Are you wanting to judge the positions solely from the number of steps they have been sent, or do you need to physically measure position?