Reputation: 1657
I need a class that uses WebBrowser
to retrive some data, and then returns that data to another class. Problem is that WebBrowser
is asyncronous and uses events, so the method that returns the data has ended before WebBrowser.DocumentCompleted
-event is fired, and no data is returned. I have to use WebBrowser
instead of WebClient
, because I need to interact with the web page.
How can I create a class that returns the data after all events are fired, and for example some boolean flag has been set?
Upvotes: 0
Views: 56
Reputation: 1038990
Ideally you should expose another event in your class that will be triggered by the WebBrowsers's DocumentCompletedEvent
. This will provide the consumers of your class the possibility to subscribe to this event as well. Otherwise you will have to block the caller's thread waiting for the webbrowser to complete which is not a good thing to do.
Upvotes: 1