IImap ClientIdle Async Method
Asynchronously toggle the ImapClient into the IDLE state.
Definition
Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
An asynchronous task context.
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
C#
Task IdleAsync(
CancellationToken doneToken,
CancellationToken cancellationToken = default
)Parameters
- doneToken CancellationToken
- The cancellation token used to return to the non-idle state.
- cancellationToken CancellationToken (Optional)
- The cancellation token.
Return Value
TaskAn asynchronous task context.
Remarks
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.
Exceptions
| 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. |