private void Form2_Load(object sender, EventArgs e)
{
AsynRun(openUrl);
}
private void openUrl()
{
this.Invoke(new bbbb(aaaa));
}
private delegate void bbbb();
private void aaaa()
{
webBrowser1.Navigate("http://www.baidu.com");
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
Application.DoEvents();
webBrowser1.document.getElementByIdx_x("kw").Focus();
SendKeys.SendWait("^v");
}
private void AsynRun(ThreadStart ts)
{
Thread thread = new Thread(ts);
thread.IsBackground = true;
thread.Start();
}
{
AsynRun(openUrl);
}
private void openUrl()
{
this.Invoke(new bbbb(aaaa));
}
private delegate void bbbb();
private void aaaa()
{
webBrowser1.Navigate("http://www.baidu.com");
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
Application.DoEvents();
webBrowser1.document.getElementByIdx_x("kw").Focus();
SendKeys.SendWait("^v");
}
private void AsynRun(ThreadStart ts)
{
Thread thread = new Thread(ts);
thread.IsBackground = true;
thread.Start();
}
本文介绍了一个使用C#实现的简单示例,通过WebBrowser控件加载指定URL(如百度首页),并演示了如何在后台线程中调用UI组件的方法。此示例还展示了如何等待页面加载完成,并对页面进行一些操作,如设置输入焦点。
3878

被折叠的 条评论
为什么被折叠?



