Esempio n. 1
0
        private async Task HandleReceiveCompleteAsync(RequestContext request)
        {
            // TODO: Add support for needToCreateSessionOpenNotificationMessage, probably in constructor
            try
            {
                if (_channel != null)
                {
                    _channel.HandleReceiveComplete(request);
                }
                else
                {
                    if (request == null && _hasSession)
                    {
                        bool close;
                        lock (ThisLock)
                        {
                            close          = !_doneReceiving;
                            _doneReceiving = true;
                        }

                        if (close)
                        {
                            await CloseBinderAsync();

                            if (_idleManager != null)
                            {
                                _idleManager.CancelTimer();
                            }

                            ServiceThrottle throttle = _throttle;
                            if (throttle != null)
                            {
                                throttle.DeactivateChannel();
                            }
                        }
                    }
                }
            }
            finally
            {
                if ((request == null) && _incrementedActivityCountInConstructor)
                {
                    _serviceDispatcher.ChannelDispatcher.Channels.DecrementActivityCount();
                }
            }
        }
Esempio n. 2
0
        private async Task HandleReceiveCompleteAsync(RequestContext request)
        {
            try
            {
                if (_channel != null)
                {
                    _channel.HandleReceiveComplete(request);
                }
                else
                {
                    if (request == null && _hasSession)
                    {
                        bool close;
                        await using (await _thisLock.TakeLockAsync())
                        {
                            close          = !_doneReceiving;
                            _doneReceiving = true;
                        }

                        if (close)
                        {
                            await CloseBinderAsync();

                            if (_idleManager != null)
                            {
                                _idleManager.CancelTimer();
                            }

                            ServiceThrottle throttle = _throttle;
                            if (throttle != null)
                            {
                                throttle.DeactivateChannel();
                            }
                        }
                    }
                }
            }
            finally
            {
                if ((request == null) && _incrementedActivityCountInConstructor)
                {
                    _serviceDispatcher.ChannelDispatcher.Channels.DecrementActivityCount();
                }
            }
        }