Lawo.EmberPlusSharp.S101.FramingStream.DisposeAsync C# (CSharp) Method

DisposeAsync() public final method

public final DisposeAsync ( CancellationToken cancellationToken ) : Task
cancellationToken System.Threading.CancellationToken
return Task
        public sealed override async Task DisposeAsync(CancellationToken cancellationToken)
        {
            if (!this.IsDisposed)
            {
                var invertedCrc = (ushort)(~this.crc & ushort.MaxValue);
                var crcBytes =
                    new[] { (byte)(invertedCrc & byte.MaxValue), (byte)((invertedCrc >> 8) & byte.MaxValue) };
                await this.WriteAsync(crcBytes, 0, crcBytes.Length, cancellationToken);

                var writeBuffer = this.WriteBuffer;
                await writeBuffer.ReserveAsync(1, cancellationToken);
                writeBuffer[writeBuffer.Count++] = Frame.EndOfFrame;
                await base.DisposeAsync(cancellationToken);
            }
        }