Just to update you on how my web page thumbnails generator (described in my post my WebBrowser experiment ) goes on...
Since this is used on a server, it , as expected, crashed a couple of times per load test... that's not very useful... I brought a little modification to it... and it didn't crashed since then.... (note that this is not on production servers)
So the first thing I do is that I load the web page using HttpWebRequest and get its stream from HttpWebResponse.GetResponseStream. Once I get the stream I create a new WebBrowser but instead of opening the page from a URL (with WebBrowser.Navigate), I load the stream that I got from HttpWebResponse into my WebBrowser's DocumentStream property. And that's it! the rest is the same as before! It's even nicer since I just get the WebBrowser.DocumentCompleted called once... I don't need to look at the URL to see if it's my main page or an embedded Flash stream... and no more about:blank called after it is completed.
So here is my new method that I have added to my ScreenCapturerSTA class:
private void CaptureMS(object obj)
{ m_byteImg = null;
MemoryStream ms = obj as MemoryStream;
try
{ using (WebBrowser webBrowser = new WebBrowser())
{ webBrowser.DocumentCompleted +=
new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);
webBrowser.Height = 1000;
webBrowser.Width = 1000;
webBrowser.ScriptErrorsSuppressed = true;
webBrowser.ScrollBarsEnabled = false;
webBrowser.DocumentStream = ms;
while (!m_done)
{ Application.DoEvents();
}
}
}
catch (Exception ex)
{ Trace.WriteLine(ex.ToString());
}
}
So, just a coincidence? I mean, the WebBrowser still has to load the content... at least it seems more stable now...
Next step? hmmm, I'm tempted by a MONO/GECKO experiment... I might give it a try...