Skip to content

Remote actor timeout cancellation #6274

Answered by Aaronontheweb
netclectic asked this question in Q&A
Discussion options

You must be logged in to vote

@netclectic to do this, you would need to incorporate the request time into the content of the message itself.

In some of my applications and our client's applications I will often include a simple readonly struct Deadline that looks like this:

// Deadline struct in C# computed from the current time and the timeout
// value. The deadline is used to determine if a request has timed out.
public readonly struct Deadline
{
    public Deadline(TimeSpan timeout)
    {
        Timeout = timeout;
        DeadlineTime = DateTime.UtcNow + timeout;
    }

    public TimeSpan Timeout { get; }
    public DateTime DeadlineTime { get; }

    public bool IsOverdue => DeadlineTime < DateTime.UtcNow;
}

I i…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@netclectic
Comment options

Answer selected by netclectic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants