Do async reads
This commit is contained in:
parent
08bba972c1
commit
cf68c18dd2
|
|
@ -46,6 +46,12 @@ namespace SocketsSample
|
||||||
|
|
||||||
while (true)
|
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())
|
while (!reader.Read())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
@ -58,7 +64,6 @@ namespace SocketsSample
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
var result = await connection.Channel.Input.ReadAsync();
|
|
||||||
if (result.IsCompleted)
|
if (result.IsCompleted)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue