Do async reads
This commit is contained in:
parent
08bba972c1
commit
cf68c18dd2
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue