异步委托
private delegate void RunSyncDelegate();
private void RunSyncCallBack(IAsyncResult iAR)
{
RunSyncDelegate runDoc = (RunSyncDelegate)iAR.AsyncState;
runDoc.EndInvoke(iAR);
}
private void SyncDealByDay()
{
//Do Something
}
//使用
RunSyncDelegate runDos = new RunSyncDelegate(SyncDealByDay);
AsyncCallback ac = new AsyncCallback(RunSyncCallBack);//异步呼叫
IAsyncResult iAResult = runDos.BeginInvoke(ac, runDos);
异步委托带参
private delegate void RunSyncDelegate(string projectGUID, string personGUID, string organizationGUID, DateTime attendanceTime, string deviceNo, string deviceName);
private void RunSyncCallBack(IAsyncResult iAR)
{
RunSyncDelegate runDoc = (RunSyncDelegate)iAR.AsyncState;
runDoc.EndInvoke(iAR);
}
private void SyncDealByDay(string projectGUID, string personGUID, string organizationGUID, DateTime attendanceTime, string deviceNo, string deviceName)
{
//Do Something
}
//使用
RunSyncDelegate runDos = new RunSyncDelegate(SyncDealByDay);
AsyncCallback ac = new AsyncCallback(RunSyncCallBack);//异步呼叫
IAsyncResult iAResult = runDos.BeginInvoke(ProjectGUID, PersonGUID, OrganizationGUID, attendanceTime, deviceNo, deviceName, ac, runDos);
非特殊说明,本文版权归 LiuCabbage 所有,转载请注明出处.
本文标题: C# 异步委托 异步委托带参