/// <summary> /// Attempt to flush any blocks to <see cref="CoapClient"/> that have been queued up. /// </summary> /// <inheritdoc/> public override async Task FlushAsync(CancellationToken cancellationToken) { _writerEvent.Set(); await FlushFinishedEvent.WaitAsync(cancellationToken); ThrowExceptionIfCaught(); }
/// <summary> /// Attempt to flush any blocks to <see cref="CoapClient"/> that have been queued up. /// </summary> /// <inheritdoc/> public override void Flush() { if (CaughtException == null && !_writerTask.IsCompleted) { _writerEvent.Set(); FlushFinishedEvent.WaitAsync(CancellationToken.None).Wait(); } ThrowExceptionIfCaught(); }
/// <inheritdoc/> public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { if (EndOfStream) { throw new EndOfStreamException("Stream ended before all bytes were written", CaughtException); } // Lets artificailly block while the writer task has blocks to write. if (_writer.Length > BlockSize) { await FlushFinishedEvent.WaitAsync(cancellationToken); } _writer.Enqueue(buffer, offset, count); _writerEvent.Set(); }