private void SetTimespanTimeout(Interop.HttpApi.HTTP_TIMEOUT_TYPE type, TimeSpan value)
{
Int64 timeoutValue;
//
// All timeouts are defined as USHORT in native layer (except MinSendRate, which is ULONG). Make sure that
// timeout value is within range.
//
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.
//
int[] currentTimeouts = _timeouts;
currentTimeouts[(int)type] = (int)timeoutValue;
_listener.SetServerTimeout(currentTimeouts, _minSendBytesPerSecond);
_timeouts[(int)type] = (int)timeoutValue;
}