Method TryStartAsync
- Namespace
- MailFathom.Application.Rules.Evaluation
- Assembly
- MailFathom.Application.dll
TryStartAsync(IPersistenceSession, MailRuleEvaluationRun, CancellationToken)
Stages a run that is starting, unless the account's row has meanwhile become one it may not replace.
Task<MailRuleEvaluationRun?> TryStartAsync(IPersistenceSession session, MailRuleEvaluationRun run, CancellationToken cancellationToken)
Parameters
sessionIPersistenceSessionThe session the write is staged in.
runMailRuleEvaluationRunThe run this request wants to start.
cancellationTokenCancellationTokenCancels the staging.
Returns
- Task<MailRuleEvaluationRun>
The run the account already has, when this request must stand down; null once the write is staged.
Remarks
Separate from SaveAsync(IPersistenceSession, MailRuleEvaluationRun, CancellationToken) because the two write for opposite reasons. A pass committing a batch owns the run it is carrying and overwrites it deliberately. A request is only entitled to the row while the row still says what it said when the request decided to write, so the check belongs beside the write rather than at the read that preceded it: between the two, another request or another schedule's occasion may have claimed the account, and an unconditional write would silently replace a wider run with a narrower one or reset a walk that was already under way. Supersedes(MailRuleEvaluationRun) is the rule this applies.