コード例 #1
0
        public async ValueTask DisposeAsync()
        {
            try
            {
                if (_confirmations != null && _model.IsOpen)
                {
                    _model.WaitForConfirms(_connectionContext.StopTimeout, out var timedOut);
                    if (timedOut)
                    {
                        LogContext.Warning?.Log("Timeout waiting for pending confirms:  {ChannelNumber} {Host}", _model.ChannelNumber,
                                                _connectionContext.Description);
                    }
                }
            }
            catch (Exception ex)
            {
                LogContext.Error?.Log(ex, "Fault waiting for pending confirms:  {ChannelNumber} {Host}", _model.ChannelNumber,
                                      _connectionContext.Description);
            }

            await _publisher.DisposeAsync().ConfigureAwait(false);

            await _executor.DisposeAsync().ConfigureAwait(false);

            const string message = "ModelContext Disposed";

            _model.Cleanup(200, message);
        }
コード例 #2
0
        public async Task DisposeAsync(CancellationToken cancellationToken)
        {
            LogContext.Debug?.Log("Closing model: {ChannelNumber} {Host}", _model.ChannelNumber, _connectionContext.Description);

            try
            {
                if (_confirmations != null && _model.IsOpen)
                {
                    bool timedOut;
                    do
                    {
                        if (cancellationToken.IsCancellationRequested)
                        {
                            break;
                        }

                        _model.WaitForConfirms(_connectionContext.StopTimeout, out timedOut);
                        if (timedOut)
                        {
                            LogContext.Warning?.Log("Timeout waiting for pending confirms:  {ChannelNumber} {Host}", _model.ChannelNumber,
                                                    _connectionContext.Description);
                        }
                    }while (timedOut);
                }
            }
            catch (Exception ex)
            {
                LogContext.Error?.Log(ex, "Fault waiting for pending confirms:  {ChannelNumber} {Host}", _model.ChannelNumber,
                                      _connectionContext.Description);
            }

            await _publisher.DisposeAsync(cancellationToken).ConfigureAwait(false);

            await _executor.DisposeAsync(cancellationToken).ConfigureAwait(false);

            const string message = "ModelContext Disposed";

            _model.Cleanup(200, message);
        }