Beispiel #1
0
    private void SetTimeSpanTimeout(HttpApiTypes.HTTP_TIMEOUT_TYPE type, TimeSpan value)
    {
        // All timeouts are defined as USHORT in native layer (except MinSendRate, which is ULONG). Make sure that
        // timeout value is within range.

        var timeoutValue = Convert.ToInt64(value.TotalSeconds);

        if (timeoutValue < 0 || timeoutValue > ushort.MaxValue)
        {
            throw new ArgumentOutOfRangeException(nameof(value));
        }

        // Use local state to get values for other timeouts. Call into the native layer and if that
        // call succeeds, update local state.
        var newTimeouts = (int[])_timeouts.Clone();

        newTimeouts[(int)type] = (int)timeoutValue;
        SetUrlGroupTimeouts(newTimeouts, _minSendBytesPerSecond);
        _timeouts[(int)type] = (int)timeoutValue;
    }
Beispiel #2
0
 private TimeSpan GetTimeSpanTimeout(HttpApiTypes.HTTP_TIMEOUT_TYPE type)
 {
     // Since we maintain local state, GET is local.
     return(new TimeSpan(0, 0, (int)_timeouts[(int)type]));
 }