Task IdleAsync( CancellationToken doneToken, CancellationToken cancellationToken = default )
|ArgumentException||doneToken must be cancellable (i.e. None cannot be used).|
|ObjectDisposedException||The ImapClient has been disposed.|
|ServiceNotConnectedException||The ImapClient is not connected.|
|ServiceNotAuthenticatedException||The ImapClient is not authenticated.|
|InvalidOperationException||A ImapFolder has not been opened.|
|NotSupportedException||The IMAP server does not support the IDLE extension.|
|OperationCanceledException||The operation was canceled via the cancellation token.|
|IOException||An I/O error occurred.|
|ImapCommandException||The server replied to the IDLE command with a NO or BAD response.|
|ImapProtocolException||The server responded with an unexpected token.|
When a client enters the IDLE state, the IMAP server will send events to the client as they occur on the selected folder. These events may include notifications of new messages arriving, expunge notifications, flag changes, etc.
Due to the nature of the IDLE command, a folder must be selected before a client can enter into the IDLE state. This can be done by opening a folder using Open(FolderAccess, CancellationToken) or any of the other variants.
While the IDLE command is running, no other commands may be issued until the doneToken is cancelled.
|It is especially important to cancel the doneToken before cancelling the cancellationToken when using SSL or TLS due to the fact that SslStream cannot be polled.|