c# 代理异步 回调
2011/1/11 8:57:32 october731 http://october731.javaeye.com
我要评论(0)
- 摘要:Class1.StuDele_dele=null;publicForm1(){InitializeComponent();}privatevoidbutton1_Click(objectsender,EventArgse){Class1c1=newClass1();AsyncCallbackcallBack=newAsyncCallback(UploadComplete);_dele+=newClass1.StuDele(Do1);IAsyncResultiResult=_dele
- 标签:C# 代理
Class1.StuDele _dele = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Class1 c1 = new Class1();
AsyncCallback callBack = new AsyncCallback(UploadComplete);
_dele += new Class1.StuDele(Do1);
IAsyncResult iResult = _dele.BeginInvoke("hha", callBack, null);
}
private void UploadComplete(IAsyncResult results)
{
System.Diagnostics.Debug.WriteLine("12345");
if (this.InvokeRequired)
{
AsyncCallback callback = new AsyncCallback(UploadComplete);
this.BeginInvoke(callback, results);
return;
}
}
string Do1(string str)
{
MessageBox.Show(str + "_1");
return "Haha Excuted Do1!";
}