Exemplo n.º 1
0
        public void Dispose()
        {
            _isDisposed = true;
            _timer?.Dispose();
            try
            {
                _requests.Writer.TryComplete();
                _task.GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                _errorCallback(ex);
            }
            finally
            {
                if (_size > 0)
                {
                    Send(_memory, _size);
                }

                var memory = Interlocked.Exchange(ref _memory, null);
                if (memory != null)
                {
                    ArrayPool <byte> .Shared.Return(memory);
                }

                _output.Finish();
            }
        }
Exemplo n.º 2
0
 public void Dispose()
 {
     _isDisposed = true;
     _timer?.Dispose();
     _requests.Writer.TryComplete();
     Flush();
     _output.Finish();
     _cancellationTokenSource.Cancel();
     _cancellationTokenSource.Dispose();
     _task.Dispose();
 }