Npgsql.WriteBuffer.DirectWriteAsyncWithSyncContext C# (CSharp) Method

DirectWriteAsyncWithSyncContext() private method

This is a hack, see explanation in NpgsqlCommand.Send.
private DirectWriteAsyncWithSyncContext ( byte buffer, int offset, int count, CancellationToken cancellationToken ) : Task
buffer byte
offset int
count int
cancellationToken System.Threading.CancellationToken
return Task
        internal async Task DirectWriteAsyncWithSyncContext(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
        {
            Contract.Assert(WritePosition == 0);
            try
            {
#pragma warning disable ConfigureAwaitChecker // CAC001
                await Underlying.WriteAsync(buffer, offset, count, cancellationToken);
#pragma warning restore ConfigureAwaitChecker // CAC001
            }
            catch (Exception e)
            {
                Connector.Break();
                throw new NpgsqlException("Exception while writing to stream", e);
            }
        }