K
Kiks
Hello, I've a question about a System.Windows.Forms.WebBrowser class that
I've instancied into my DLL.
I would like to navigate to a page and catch the
System.Windows.Forms.HtmlDocument that my WebBrowser Navigated to.
I have tried different solutions, but I found problems in them all:
In this first solution, always my function ApriIE return NULL, and the
WebBrowser seems to open the URL only after my application finishes.
private System.Windows.Forms.HtmlDocument ApriIE()
{
String URL = https://www.cartasi.it;
System.Windows.Forms.WebBrowser browser = new
System.Windows.Forms.WebBrowser();
Exception e = new Exception();
DateTime start = DateTime.Now;
TimeSpan timeout = new TimeSpan(0, 0, 10);
browser.Navigate(URL, true);
try
{
browser.Navigate(vPostehRef, true);
while (browser.IsBusy)
{
System.Windows.Forms.Application.DoEvents();
if (DateTime.Now - start > timeout) throw e;
}
return browser.Document;
}
catch
{
return null;
}
In this second solution, the browser_DocumentCompleted Event never fires:
private System.Windows.Forms.HtmlDocument ApriIE()
{
System.Windows.Forms.WebBrowser browser = new
System.Windows.Forms.WebBrowser();
browser.DocumentCompleted+=new
System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(browser_DocumentCompleted);
Exception e = new Exception();
DateTime start = DateTime.Now;
TimeSpan timeout = new TimeSpan(0, 0, 10);
browser.Navigate(vPostehRef, true);
try
{
browser.Navigate(vPostehRef, true);
while (browser.IsBusy)
{
System.Windows.Forms.Application.DoEvents();
if (DateTime.Now - start > timeout) throw e;
}
return browser.Document;
}
catch
{
return null;
}
}
private void browser_DocumentCompleted( Object sender,
System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
{
doc = (System.Windows.Forms.HtmlDocument)sender;
}
Any ideas?
Thanks to all,
Kiks
I've instancied into my DLL.
I would like to navigate to a page and catch the
System.Windows.Forms.HtmlDocument that my WebBrowser Navigated to.
I have tried different solutions, but I found problems in them all:
In this first solution, always my function ApriIE return NULL, and the
WebBrowser seems to open the URL only after my application finishes.
private System.Windows.Forms.HtmlDocument ApriIE()
{
String URL = https://www.cartasi.it;
System.Windows.Forms.WebBrowser browser = new
System.Windows.Forms.WebBrowser();
Exception e = new Exception();
DateTime start = DateTime.Now;
TimeSpan timeout = new TimeSpan(0, 0, 10);
browser.Navigate(URL, true);
try
{
browser.Navigate(vPostehRef, true);
while (browser.IsBusy)
{
System.Windows.Forms.Application.DoEvents();
if (DateTime.Now - start > timeout) throw e;
}
return browser.Document;
}
catch
{
return null;
}
In this second solution, the browser_DocumentCompleted Event never fires:
private System.Windows.Forms.HtmlDocument ApriIE()
{
System.Windows.Forms.WebBrowser browser = new
System.Windows.Forms.WebBrowser();
browser.DocumentCompleted+=new
System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(browser_DocumentCompleted);
Exception e = new Exception();
DateTime start = DateTime.Now;
TimeSpan timeout = new TimeSpan(0, 0, 10);
browser.Navigate(vPostehRef, true);
try
{
browser.Navigate(vPostehRef, true);
while (browser.IsBusy)
{
System.Windows.Forms.Application.DoEvents();
if (DateTime.Now - start > timeout) throw e;
}
return browser.Document;
}
catch
{
return null;
}
}
private void browser_DocumentCompleted( Object sender,
System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
{
doc = (System.Windows.Forms.HtmlDocument)sender;
}
Any ideas?
Thanks to all,
Kiks