Lawo.EmberPlusSharp.S101.S101Writer.WriteOutOfFrameByteCoreAsync C# (CSharp) Method

WriteOutOfFrameByteCoreAsync() private method

private WriteOutOfFrameByteCoreAsync ( byte value, CancellationToken cancellationToken ) : Task
value byte
cancellationToken System.Threading.CancellationToken
return Task
        private async Task WriteOutOfFrameByteCoreAsync(byte value, CancellationToken cancellationToken)
        {
            this.AssertNotDisposed();

            if (value == Frame.BeginOfFrame)
            {
                var message = string.Format(
                    CultureInfo.InvariantCulture, "A value not equal to {0:X2} is required.", Frame.BeginOfFrame);
                throw new ArgumentException(message, nameof(value));
            }

            if ((this.stream == null) || !this.stream.CanWrite)
            {
                await this.writeBuffer.ReserveAsync(1, cancellationToken);
                this.writeBuffer[this.writeBuffer.Count++] = value;
                await this.writeBuffer.FlushAsync(cancellationToken);
            }
            else
            {
                await this.stream.WriteOutOfFrameByteAsync(value, cancellationToken);
            }
        }