if (win != null)
{
doc = (HtmlDocument)win.GetProperty("document");
doc.Invoke("write", s);
win.Eval("location:reload();");
}
if (win != null)
{
doc = (HtmlDocument)win.GetProperty("document");
BackgroundWorker bcwk = new BackgroundWorker();
bcwk.DoWork+=new DoWorkEventHandler(bcwk_DoWork);
bcwk.RunWorkerAsync();
bcwk.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bcwk_RunWorkerCompleted);
}
static void bcwk_DoWork(object sender,DoWorkEventArgs e)
{
// WriteHtml((BackgroundWorker)sender, e);
WriteHtml2();
}
static void bcwk_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
win.Eval("location.reload();");
MessageBox.Show("方法调用完毕");
}
public static void WriteHtml2()
{
if (doc != null)
{
doc.Invoke("write", s);
}
}
public static void WriteHtml(BackgroundWorker worker,DoWorkEventArgs e)
{
if (doc != null)
{
doc.Invoke("write", s);
}
}
只能在ui线程调用指的是messagebox吧
另外RunWorkerCompleted 事件应该在RunWorkerAsync()方法调用之前注册