//定义与方法同签名的委托
private delegate void AL_DelegateName(List<AL_ProductList> finishedList, string sourceDir, string saveDir, bool jinYi, bool maoLian, bool product, bool FTP, DateTime dtStart, DateTime dtEnd, string name);
private void AL_CallBackMethod(IAsyncResult ar)
{
//从异步状态ar.AsyncState中,获取委托对象
AL_DelegateName dn = (AL_DelegateName)ar.AsyncState;
//输出参数
int i;
//一定要EndInvoke,否则你的下场很惨
dn.EndInvoke(ar);
XtraMessageBox.Show("OK");
//try
//{
// this.pictureBox1.Visible = false;
//}
//catch (Exception)
//{
// this.pictureBox1.Visible = false;
//}
// MessageBox.Show("异步完成喽!i的值是" i.ToString() ",r的值是" r);
}
private void loadone()
{
#region
//实例化委托并初赋值
AL_DelegateName dn = new AL_DelegateName(new Actor.AliActor().ConvertMethod);
//输出参数
int i;
//实例化回调方法
//把AsyncCallback看成Delegate你就懂了,实际上AsyncCallback是一种特殊的Delegate,就像Event似的
AsyncCallback acb = new AsyncCallback(AL_CallBackMethod);
//pictureBox1.Visible = true;
//异步开始
//如果参数acb换成null则表示没有回调方法
//最后一个参数dn的地方,可以换成任意对象,该对象可以被回调方法从参数中获取出来,写成null也可以。参数dn相当于该线程的ID,如果有多个异步线程,可以都是null,但是绝对不能一样,不能是同一个object,否则异常
IAsyncResult iar = dn.BeginInvoke(finishedList, this.txtSourceDir.Text, this.txtSaveDir.Text, cktJinYi.Checked, cktProduct.Checked, cktMaoLian.Checked, ckFTP.Checked,
dtStart, dtEnd, cbbSite.Text, acb, dn);
//去做别的事
#endregion
}