Table of Contents

Method RenewAsync

Namespace
MailFathom.Application.Coordination
Assembly
MailFathom.Application.dll

RenewAsync(WorkScope, WorkLeaseHolder, TimeSpan, CancellationToken)

Pushes a held lease further out, so a long-running hold is not taken from underneath it.

Task<WorkLease?> RenewAsync(WorkScope scope, WorkLeaseHolder holder, TimeSpan leaseDuration, CancellationToken cancellationToken)

Parameters

scope WorkScope

The scope whose lease is renewed.

holder WorkLeaseHolder

The hold claiming to hold it.

leaseDuration TimeSpan

How much longer the scope is held from now.

cancellationToken CancellationToken

Cancels the write.

Returns

Task<WorkLease>

The renewed lease, or null when this hold no longer holds the scope.

Remarks

An absent answer is the signal to stop working, and to stop at once rather than at the next pass: the scope belongs to another hold, so anything this one goes on to commit would be a second writer's.

The condition is the holder rather than the expiry, so a hold whose lease has run out but which nothing has taken renews it and goes on working. That is safe because nothing else holds the scope, and refusing on the expiry instead would abandon work nobody else had taken.

Exceptions

ArgumentNullException

Thrown when scope or holder is null.

ArgumentOutOfRangeException

Thrown when leaseDuration is not positive.