private void OnTimeout(object stateObj)
        {
            var state = (OperationState)stateObj;
            var ex    = new OperationTimedOutException(EndPoint, state.TimeoutMillis);
            //Invoke if it hasn't been invoked yet
            //Once the response is obtained, we decrement the timed out counter
            var timedout = state.MarkAsTimedOut(ex, () => Interlocked.Decrement(ref _timedOutOperations), GetTimestamp());

            if (!timedout)
            {
                //The response was obtained since the timer elapsed, move on
                return;
            }
            //Increase timed-out counter
            Interlocked.Increment(ref _timedOutOperations);
        }
示例#2
0
        private void OnTimeout(object stateObj)
        {
            var streamId = (short)stateObj;

            if (!_pendingOperations.TryGetValue(streamId, out var state))
            {
                return;
            }
            var ex = new OperationTimedOutException(EndPoint, state.TimeoutMillis);
            //Invoke if it hasn't been invoked yet
            //Once the response is obtained, we decrement the timed out counter
            var timedout = state.MarkAsTimedOut(ex, () => Interlocked.Decrement(ref _timedOutOperations));

            if (!timedout)
            {
                //The response was obtained since the timer elapsed, move on
                return;
            }
            //Increase timed-out counter
            Interlocked.Increment(ref _timedOutOperations);
        }