Do async reads

This commit is contained in:
David Fowler 2016-10-09 02:34:42 -07:00
parent 08bba972c1
commit cf68c18dd2
1 changed files with 6 additions and 1 deletions

View File

@ -46,6 +46,12 @@ namespace SocketsSample
while (true)
{
// JSON.NET doesn't handle async reads so we wait for data here
var result = await connection.Channel.Input.ReadAsync();
// Don't advance the buffer so we parse sync
connection.Channel.Input.Advance(result.Buffer.Start);
while (!reader.Read())
{
break;
@ -58,7 +64,6 @@ namespace SocketsSample
}
catch (Exception)
{
var result = await connection.Channel.Input.ReadAsync();
if (result.IsCompleted)
{
break;