c# - I want to know how to control the flow of code when using webbrowser? -


i have loop , in loop call

   webbrowser.navigate("www.example.com"); 

after know documentcompleted function called , work int function ,but after work done ,nothing happens code not come loop , flow in loops.am doing wrong.

thank you

this problem caused having loop. web browser's navigation can complete , documentcompleted event can fire when ui thread goes idle again. core way multi-threaded components work, can fire 'the job done' event on ui thread when ui thread idle , pumps message loop. backgroundworker class example has exact same requirement.

the proper way solve create state machine. kick off telling browser navigate first url. let documentcompleted event handler process response , tell browser navigate next url. or stop when there no more urls process.

the improper way call application.doevents() in loop. pumps message loop , allows events fire. dangerous thing do, doevents() not selective what events processed. sure read this answer if contemplate using anyway.

the next way upcoming support async , await keywords in next version of c#. available in ctp.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -