Look at this code:
delegate void SetBrowserContentDelegate(WebBrowser b);
if (browser.InvokeRequired)
{
browser.Invoke(new SetBrowserContentDelegate(SetBrowserContent), browser);
}
else
{
browser.BringToFront();
browser.DocumentText = "<html><body>example</body></html>";
//this code here is executed and it gives an error saying this "Cross-thread operation..."
}
void SetBrowserContent(WebBrowser b)
{
b.BringToFront();
b.DocumentText = message_;
}
My question is why the SetBrowserContent method is not executed?The exception says that the form(i mean the form where the 'browser' is) is accessed by thread other than the thread it's created on.I'm fairly new to C# programming and this threads and delegates are very obscure to me,i'm doing something wrong but don't know what...Sorry for my bad english.Thanks in advance.