Found almost everything to work with this component, except for one thing - how can I create an instance of an object in the background thread?
If you create like this:
WebControl browser = new WebControl(); browser.Source = new Uri("http://wtfismyip.com/text"); then does not want to send requests (or accept the answer, and did not understand). No exceptions, just browser.HTML is empty.
It works only like this:
WebControl browser = new WebControl(); Controls.Add(browser); browser.Source = new Uri("http://wtfismyip.com/text"); but then you need to break into the UI stream.
All would be fine if they need 2 or 3, but the execution of such code here:
for (int i = 0; i < 50; i++) { browsers[i] = new WebControl(); webPreferences[i] = new WebPreferences(true); webSessionProvider[i] = new WebSessionProvider(); webPreferences[i].ProxyConfig = proxy[i]; webSessionProvider[i].Preferences = new WebSessionProvider(); webSessionProvider[i].Views.Add(browsers[i]); Controls.Add(browsers[i]); } can freeze the form for 30-60s (did not measure it exactly, but Windows manages to mark the application as "not responding"). How can I create and use this component completely in the background thread?
To have something like:
private async Task Do() { for (int i = 0; i < 9; i++) { browsers[i] = new WebControl(); webPreferences[i] = new WebPreferences(true); webSessionProvider[i] = new WebSessionProvider(); webPreferences[i].ProxyConfig = proxy[i]; webSessionProvider[i].Preferences = webPreferences[i]; webSessionProvider[i].Views.Add(browsers[i]); browsers[i].Source = new Uri("http://wtfismyip.com/text"); while (browsers[i].IsLoading) { await Task.Delay(500); } } }