Method ReadCandidatesAsync
- Namespace
- MailFathom.Application.Synchronization.Drain
- Assembly
- MailFathom.Application.dll
ReadCandidatesAsync(MailAccountId, IReadOnlyCollection<MailFolderAlias>, int, CancellationToken)
Reads the oldest messages of a held account that its source still holds.
Task<IReadOnlyList<MailboxDrainCandidate>> ReadCandidatesAsync(MailAccountId account, IReadOnlyCollection<MailFolderAlias> drainableFolders, int maximumCandidates, CancellationToken cancellationToken)
Parameters
accountMailAccountIdThe account.
drainableFoldersIReadOnlyCollection<MailFolderAlias>The aliases whose folder the source keeps messages of its own in.
maximumCandidatesintThe most messages one pass takes in hand.
cancellationTokenCancellationTokenPropagates caller cancellation.
Returns
- Task<IReadOnlyList<MailboxDrainCandidate>>
The candidates, oldest first, bounded by what was asked for, and none from any other folder.
Remarks
Oldest first so a mailbox of years empties from the end nobody is reading, and bounded so one pass costs a bounded number of reads whatever the mailbox holds. Every candidate carries an occurrence: a row whose occurrence was cleared has already been drained and is not asked about again.
Exceptions
- ArgumentNullException
Thrown when
drainableFoldersis null.- ArgumentOutOfRangeException
Thrown when
maximumCandidatesis not positive.