/// <summary> /// 发送邮件提醒,并更新消息状态 /// </summary> public void SendMail() { List <MessageEntity> messages = DBOperate.LoadAlertMessage(Enum_MessageType.Mail.ToString()); //Parallel.ForEach(messages, msg => //{ // delegate_SendMail(msg); //}); //异步发送 foreach (MessageEntity msg in messages) { delegate_SendMail(msg); ////带返回值 //SendMailDelegate fh = new SendMailDelegate(this.delegate_SendMail); //IAsyncResult ar = fh.BeginInvoke(msg, null, fh); //while (!ar.IsCompleted) //{ // Thread.Sleep(100); //} //msg.IsSended = fh.EndInvoke(ar); } //DBOperate.UpdateMessageStatus(messages); }