I implemented my own NetworkStream
port for Silverlight which only allows asynchronous calls.
JsonTextReader
so I ended up with the following code:
reader = new JsonTextReader(new StreamReader(new NetworkStream(new Sock开发者_如何学Cet(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))));
// ...
reader.Read();
My problem is that it will attempt to perform a synchronous operation which in turn just throw UnsupportedException
.
StreamReader
that I can feed the JsonTextReader
with?
Should I take another approach?I think you should. I don't think you can force JsonTextReader to use async approach, but you could modify the entire method used for getting data to behave asynchronously. Also, use
using(var io = new StreamReader())
{
io.Read();
}
syntax.
精彩评论