Reputation: 3327
I'm using WebBrowser and when I'm trying to call .Navigate(some_local_html)
then nothing is displayed on my browser. If I then use MessageBox.Show()
, then while message is shown I can see my html in browser. But when I close MessageBox
, html is missing again.
I've tried Try-catch, but there was no errors.
I was trying to set default url on webBrowser
control, and there is no result also. I can see nothing.
RESOLVED:
That wasn't a thread itself, but some kind of thread. I added next code:
Stream stream = null;
webBrowser1.DocumentStream = stream;
and forgot to remove it... That's a reason. Thanks everyone!
Upvotes: 1
Views: 2159
Reputation: 1006
It'd be helpful to know where you are calling your navigate and MessageBox functions. I quickly created a test to see if I could produce a similar result but the code below worked exactly as expected.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.webBrowser1.Navigate("http://www.google.com");
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Some Text");
}
}
Upvotes: 1
Reputation: 18445
Not sure if this will help at all, but it sounds like something is redrawing in the background, as when you put a messagebox up I am sure it sleeps the thread so nothing else can happen until it has been actioned, so whatever is overwriting it would be stopped temporarily.
If you do have something on that thread refreshing or redrawing frequently that could be causing your problems, try adding a button to your form which does a thread.sleep(1000) to see if that correctly displays your browser for a second.
Upvotes: 1