Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams committed Dec 20, 2018
1 parent d35c70a commit 9adbdcd
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ internal class SNIPacket : IDisposable, IEquatable<SNIPacket>

private ArrayPool<byte> _arrayPool = ArrayPool<byte>.Shared;
private bool _isBufferFromArrayPool = false;
private ValueTask _asyncOperation;

public SNIPacket() { }

Expand Down Expand Up @@ -239,7 +238,6 @@ public void Reset()
_offset = 0;
_description = null;
_completionCallback = null;
_asyncOperation = default;
}

/// <summary>
Expand All @@ -250,7 +248,7 @@ public void Reset()
public void ReadFromStreamAsync(Stream stream, SNIAsyncCallback callback)
{
// Treat local function as a static and pass all params otherwise as async will allocate
async ValueTask ReadFromStreamAsync(SNIPacket packet, SNIAsyncCallback cb, ValueTask<int> valueTask)
async Task ReadFromStreamAsync(SNIPacket packet, SNIAsyncCallback cb, ValueTask<int> valueTask)
{
bool error = false;
try
Expand Down Expand Up @@ -292,7 +290,7 @@ async ValueTask ReadFromStreamAsync(SNIPacket packet, SNIAsyncCallback cb, Value
}

// Not complete or error call the async local function to complete
_asyncOperation = ReadFromStreamAsync(this, callback, vt);
_ = ReadFromStreamAsync(this, callback, vt);
}

/// <summary>
Expand Down Expand Up @@ -320,7 +318,7 @@ public void WriteToStream(Stream stream)
public void WriteToStreamAsync(Stream stream, SNIAsyncCallback callback, SNIProviders provider, bool disposeAfterWriteAsync = false)
{
// Treat local function as a static and pass all params otherwise as async will allocate
async ValueTask WriteToStreamAsync(SNIPacket packet, SNIAsyncCallback cb, SNIProviders providers, bool disposeAfter, ValueTask valueTask)
async Task WriteToStreamAsync(SNIPacket packet, SNIAsyncCallback cb, SNIProviders providers, bool disposeAfter, ValueTask valueTask)
{
uint status = TdsEnums.SNI_SUCCESS;
try
Expand All @@ -345,6 +343,9 @@ async ValueTask WriteToStreamAsync(SNIPacket packet, SNIAsyncCallback cb, SNIPro

if (vt.IsCompletedSuccessfully)
{
// Read the result to register as complete for the ValueTask
vt.GetAwaiter().GetResult();

callback(this, TdsEnums.SNI_SUCCESS);

if (disposeAfterWriteAsync)
Expand All @@ -357,7 +358,7 @@ async ValueTask WriteToStreamAsync(SNIPacket packet, SNIAsyncCallback cb, SNIPro
}

// Not complete or error call the async local function to complete
_asyncOperation = WriteToStreamAsync(this, callback, provider, disposeAfterWriteAsync, vt);
_ = WriteToStreamAsync(this, callback, provider, disposeAfterWriteAsync, vt);
}

/// <summary>
Expand Down

0 comments on commit 9adbdcd

Please sign in to comment.