日期:2014-05-17 浏览次数:20969 次
this.BeginInvoke(new dlgGetData(getData), url, textBox1);
private void Form1_Load(object sender, EventArgs e)
{
Action<string> action = new Action<string>(DoWork);
AsyncCallback callback = new AsyncCallback(Callback);
action.BeginInvoke("你要传的参数", callback, action);
}
protected void Callback(IAsyncResult ar)
{
Action<string> dlgt = (Action<string>)ar.AsyncState;
dlgt.EndInvoke(ar);
}
protected void DoWork(string msg)
{
Thread.Sleep(1000);//耗时操作
Action<string> action=delegate{ label1.Text=msg;}; //界面更新