rotary encoder does not work when pulseIn active

How can I count the pulses another way?

Connect whatever is generating the pulses to a pin that supports external interrupts, and attach an interrupt handler.