public static void SendMail(MailDataEntity mailDataEntity) { SendMailDelegate <List <TaobaoProduct> > ThirdPartMappingNotExists = new SendMailDelegate <List <TaobaoProduct> >(SendMail); SendMailDelegate <List <ThirdPartInventoryEntity> > TaobaoProductNotExists = new SendMailDelegate <List <ThirdPartInventoryEntity> >(SendMail); SendMailDelegate <Dictionary <ThirdPartInventoryEntity, TaobaoProduct> > InventoryQtyNotEquels = new SendMailDelegate <Dictionary <ThirdPartInventoryEntity, TaobaoProduct> >(SendMail); IAsyncResult ThirdPartMappingNotExists_Result = ThirdPartMappingNotExists.BeginInvoke(mailDataEntity.ThirdPartMappingNotExists, null, null); IAsyncResult TaobaoProductNotExists_Result = TaobaoProductNotExists.BeginInvoke(mailDataEntity.TaobaoProductNotExists, null, null); IAsyncResult InventoryQtyNotEquels_Result = InventoryQtyNotEquels.BeginInvoke(mailDataEntity.InventoryQtyNotEquels, null, null); ThirdPartMappingNotExists.EndInvoke(ThirdPartMappingNotExists_Result); TaobaoProductNotExists.EndInvoke(TaobaoProductNotExists_Result); InventoryQtyNotEquels.EndInvoke(InventoryQtyNotEquels_Result); }
private static void SendMail(List <MailEntity> mailList) { SendMailBiz biz = new SendMailBiz(); List <SendMailDelegate <MailEntity> > delegateList = new List <SendMailDelegate <MailEntity> >(); List <IAsyncResult> resultList = new List <IAsyncResult>(); for (int i = 0; i < mailList.Count; i++) { MailEntity entity = mailList[i]; SendMailDelegate <MailEntity> sendMail = new SendMailDelegate <MailEntity>(biz.SendMail); delegateList.Add(sendMail); resultList.Add(sendMail.BeginInvoke(entity, null, null)); } for (int i = 0; i < delegateList.Count; i++) { SendMailDelegate <MailEntity> mailDelegate = delegateList[i]; mailDelegate.EndInvoke(resultList[i]); } }