public delegate int myPlus();
public static int i; private void simpleButton1_Click(object sender, EventArgs e)
{
this.progressBarControl1.Properties.ShowTitle = true;
//this.progressBarControl1.Properties.PercentView = true;
myPlus plus = new myPlus(stepPlus);
IAsyncResult iftAR = plus.BeginInvoke(new AsyncCallback(stepPlusComplete), null); } static void stepPlusComplete(IAsyncResult itfAR)
{
AsyncResult ar = (AsyncResult)itfAR;
myPlus plus = (myPlus)ar.AsyncDelegate;
i = plus.EndInvoke(itfAR); }
public static int stepPlus()
{
int my = 0;
for (int i = 0; i < 10; i++)
{
i++;
my = i;
Thread.Sleep(1000);
}
return my;
}stepPlusComplete函数只能有一个IAsyncResult参数吗?又必须是static,我怎么能把得出的结果提出来?this.textbox1.text=i.tostring()?
这个就是返回你的异步调用的结果啊!
static void stepPlusComplete(IAsyncResult itfAR)
随便你定义参数的个数和类型啊!怎么这么死板呢