C# 为什么client.GetMessage会在这两者之间阻塞?
我正在尝试从pop服务器下载看不见的电子邮件。我正在尝试从openPop.net的官方网站下载此codecopied 在那之后,调试按钮就不起作用了。即使我按F10键,它也不起作用。 如果我不调试代码,让应用程序运行,那么它会继续运行,永远不会退出循环。C# 为什么client.GetMessage会在这两者之间阻塞?,c#,pop3,openpop,C#,Pop3,Openpop,我正在尝试从pop服务器下载看不见的电子邮件。我正在尝试从openPop.net的官方网站下载此codecopied 在那之后,调试按钮就不起作用了。即使我按F10键,它也不起作用。 如果我不调试代码,让应用程序运行,那么它会继续运行,永远不会退出循环。 我做错了什么?谢谢你找到解决办法了吗? public static List<OpenPop.Mime.Message> FetchUnseenMessages(string hostname, int port, bool use
我做错了什么?谢谢你找到解决办法了吗?
public static List<OpenPop.Mime.Message> FetchUnseenMessages(string hostname, int port, bool useSsl, string username, string password, List<string> seenUids)
{
// The client disconnects from the server when being disposed
using (Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(hostname, port, useSsl);
// Authenticate ourselves towards the server
client.Authenticate(username, password,AuthenticationMethod.UsernameAndPassword);
// Fetch all the current uids seen
List<string> uids = client.GetMessageUids();
// Create a list we can return with all new messages
List<OpenPop.Mime.Message> newMessages = new List<OpenPop.Mime.Message>();
// All the new messages not seen by the POP3 client
for (int i = 0; i < uids.Count; i++)
{
string currentUidOnServer = uids[i];
if (!seenUids.Contains(currentUidOnServer))
{
// We have not seen this message before.
// Download it and add this new uid to seen uids
// the uids list is in messageNumber order - meaning that the first
// uid in the list has messageNumber of 1, and the second has
// messageNumber 2. Therefore we can fetch the message using
// i + 1 since messageNumber should be in range [1, messageCount]
OpenPop.Mime.Message unseenMessage = client.GetMessage(i + 1);
// Add the message to the new messages
newMessages.Add(unseenMessage);
// Add the uid to the seen uids, as it has now been seen
seenUids.Add(currentUidOnServer);
}
}
// Return our new found messages
//client.Disconnect();
return newMessages;
}
}
OpenPop.Mime.Message unseenMessage = client.GetMessage(i + 1);