小编Xio*_*lin的帖子

MailKit IMAP Idle - 如何在 CountChanged 事件中访问“完成”CancellationTokenSource

我正在使用此处找到的 IMAP Idle 示例代码

该示例需要 Console.ReadKey 来取消 CancellationTokenSource,但建议只要该事件有权访问 CancellationTokenSource,就可以在新邮件到达时在 CountChanged 事件中取消它。

如何访问 CountChanged 事件中的 CancellationTokenSource?

这是上面链接中的代码片段......

// Keep track of changes to the number of messages in the folder (this is how we'll tell if new messages have arrived).
client.Inbox.CountChanged += (sender, e) => {
    // Note: the CountChanged event will fire when new messages arrive in the folder and/or when messages are expunged.
    var folder = (ImapFolder)sender;

Console.WriteLine("The number of messages in {0} has changed.", folder);

    // Note: …
Run Code Online (Sandbox Code Playgroud)

c# imap mailkit

2
推荐指数
1
解决办法
1937
查看次数

标签 统计

c# ×1

imap ×1

mailkit ×1