LAZY <t>枚举的慢度

时间:2018-11-06 11:09:00

标签: c# lazy-sequences

ic = new ImapClient("imap.yandex.com", Email, email.Password, AuthMethods.Login, 993, true);
var mailMessage = ic.SearchMessages(SearchCondition.From("somemail@gmail.com"), false, true).ToList();

if (mailMessage.Count > 0)
{
    foreach (Lazy<AE.Net.Mail.MailMessage> Lmail in mailMessage)
    {
        AE.Net.Mail.MailMessage mail = Lmail.Value;
        //SendSmtpMail(mail.Subject, ReplyData, Email, Password, mail.From,mail.MessageID);
        if (mail != null)
        {
            if (mail.To.FirstOrDefault(x => x.Equals(email.EmailName)) != null)
            {
                if (mail.Body.IndexOf("Attachment Name:", StringComparison.OrdinalIgnoreCase) > -1)
                {
                    Code= Between(mail.Body, "to:", "\r");
                }
                else
                {
                    _msg.Add("CODE NOT FOUND..." + Environment.NewLine);
                }
            }
        }
    }
}

我正在使用nuget的AE Mail插件。问题是,下面这行:

AE.Net.Mail.MailMessage mail = Lmail.Value; 

花费了将近1秒的时间进行了惰性枚举。解析大量邮件时,这很麻烦。有什么建议吗?

0 个答案:

没有答案