public void StartIdle()
{
if (!ServerCapability.IsIdleSupported) {
const string message = "Server does not support the idle command. Please check Capability.CanIdle before calling Idle.";
throw new InvalidOperationException(message);
}
var command = new ImapCommand("IDLE");
SendAndReceive(command);
IsIdling = true;
while (true) {
// Need to set response timeout to 29 minutes, because the server will kick us after 30 if we do not re apply for IDLE.
ResponseTimeout = TimeSpan.FromMinutes(29);
var reader = new ImapResponseReader(this);
try {
ReceiveIdleStatusUpdates(reader);
}
catch (TimeoutException) {
StopIdleAsync();
}
if (reader.IsCompleted) {
break;
}
}
IsIdling = false;
}
public void ThreadStart() { _clientIdle = AccountController.CreateClientByAccount(AccountController.Account); Thread.Sleep(1000); _clientIdle.StatusUpdateReceived += OnStatusUpdateReceived; _clientIdle.Select("INBOX"); _clientIdle.StartIdle(); }