I'm not sure, but it sounds like the slider(?) is generating lots of events?
Maybe you could disable the slider as you start the procedure and re-enable it before you exit the procedure?
Also the line above...
if(p1 ==0 ||p2 ==0 || p ==0)
Shouldnt that be?
if(p1 ==0 ||p2 ==0 || p3 ==0)