dotnet / SqlClient

Microsoft.Data.SqlClient provides database connectivity to SQL Server for .NET applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improvement of transport creation handler: cancellation/timeouts, chain of responsibility for other types of transport

benrr101 opened this issue · comments

I have a simple enough TimedCancellationToken class which might help to handle cancellations and timeouts properly (and to time the end-to-end operation more precisely - using Stopwatches rather than DateTimes.) The initial API shape is

public sealed class TimedCancellationToken : IDisposable
{
    public TimeSpan ElapsedTime { get; }
    public TimeSpan RemainingTime { get; }
    public TimeSpan TimeoutPeriod { get; }
    public CancellationToken Token { get; }

    public TimedCancellationToken(TimeSpan timeout, CancellationToken userCancellationToken) { }

    public void Start() { }
    public void ThrowIfCancellationRequestedOrTimedOut(out bool userCancellationRequested) { }
    public void Dispose() { }
}

Is this needed? If so, which PR would it be most useful in?