Reading email programmatically app not responding message

view story

http://stackoverflow.com – I was able to read emails programmatically but not without a problem. The "app not responding" message dialog box pops up. After clicking wait the app works fine. How do I resolve this problem because I just could not get past this. Every time I have to respond to this dialog when reading emails. Sending works fine. I appreciate your help. (HowTos)