public void CallBackThread() { foreach (var th in thList) { if (Thread.CurrentThread == th.th) { lock (obj) { th.Status = -1; num--; if (SendQueue.Count > 0) { var item = SendQueue.Dequeue(); MailObject mail = new MailObject(item.From.Server, item.From.Port.Value, item.From.UserName, item.From.PassWord, subject, item.SendMail, tocount, item.ToCount, imgPath, item.StartID); mail.SendResult += mail_SendResult; Thread thh = new Thread(mail.Send); AddThread(thh); } Start(); } break; } } }
public void AddData(List <SendData> data) { data.ForEach(item => { if (thList.Count < maxNum) { MailObject mail = new MailObject(item.From.Server, item.From.Port.Value, item.From.UserName, item.From.PassWord, subject, item.SendMail, tocount, item.ToCount, imgPath, item.StartID); mail.SendResult += mail_SendResult; Thread th = new Thread(mail.Send); th.Name = item.SendMail; AddThread(th); } else { SendQueue.Enqueue(new SendData() { From = item.From, Message = item.Message, Press = item.Press, SendMail = item.SendMail, ToCount = item.ToCount }); } }); }