14 10 2022

异步委托

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);

延伸阅读
  1. IIS设置网站为HTTPS并且将HTTP重定向到HTTPS
  2. input 设置 display:none后 jquery无法给input赋值
发表评论