public void Execute() { List <Mail> mailList = new List <Mail>(); foreach (KeyValuePair <int, MailProvider> item in MailProvider.Providers) { int standByPeriod = 1; MailProvider provider = item.Value; if (provider.StandbyPeriod > standByPeriod) { standByPeriod = provider.StandbyPeriod; } SendMailList(MailQueue.Fetch(provider)); Thread.Sleep(standByPeriod * 1000); } mailList.AddRange(MailQueue.Fetch()); SendMailList(mailList); mailList.AddRange(MailQueue.Fetch()); }