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);
}
}