C# Windows Form 下通过MethodInvoker 实现异步调用 (不使用thread)
Posted on 2010-04-03 16:31 talantlee 阅读(2289) 评论(1) 编辑 收藏 举报
public class testForm:Form
{
...
...
public void test()
{
System.Windows.Forms.MethodInvoker CallToRefreshGrid = new System.Windows.Forms.MethodInvoker (this.RefreshGrid);
this.BeginInvoke(CallToRefreshGrid);
}
private void RefreshGrid()
{
dataGrid1.DataSource = appData.Tables[0].DefaultView;
dataGrid1.Refresh();
}
}
{
...
...
public void test()
{
System.Windows.Forms.MethodInvoker CallToRefreshGrid = new System.Windows.Forms.MethodInvoker (this.RefreshGrid);
this.BeginInvoke(CallToRefreshGrid);
}
private void RefreshGrid()
{
dataGrid1.DataSource = appData.Tables[0].DefaultView;
dataGrid1.Refresh();
}
}