c# - WebBrowser control executing from service issue -


ok, here's deal -- i'm running windows forms webbrowser control service. know thats no-no, seems work alright.

the thing i'm running problem trying wait browser's pages load. in normal application, i'd like

while (browser.readystate != complete) application.doevents() 

obviously won't work service.

i've tried alternative:

public class webcrawler {     private class exposedactivexwebbrowser : system.windows.forms.webbrowser     {         public shdocvw.webbrowser underlyingwebbrowser         {                         {                 return activexinstance shdocvw.webbrowser;             }         }     }     exposedactivexwebbrowser worker;      public webbrowserreadystate readystate     {                 {             return worker.readystate;         }     }      public htmldocument document     {                 {            return worker.document;         }     }      public webcrawler()     {         worker = new exposedactivexwebbrowser();     }      public void navigate(string urlstring)     {         worker.navigate(urlstring);         while (worker.underlyingwebbrowser.readystate != tagreadystate.readystate_complete)             thread.sleep(0);     } } 

that navigate method, however, doesn't work. readystate never changes loading.

what i'm wondering -- windows forms webbrowsers seem inherently asynchronous, mean activex control executing on own thread?

can i, accessing underlying activex control through appropriate interface, wait complete?

you try documentcompleted event.

from msdn:

occurs when webbrowser control finishes loading document.

...

handle documentcompleted event receive notification when new document finishes loading. when documentcompleted event occurs, new document loaded, means can access contents through document, documenttext, or documentstream property.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -