A limitation of the protobuf-net implementation is that it calls the underlying streams synchronously. By not offering an asynchronous API e.g. BeginSerialize/EndSerialize or a TPL equivalent, we are forced to tie up a thread waiting for synchronous stream I/O.
Is there any plan to offer asynchronous methods in protobuf-net, or alternatively, any creative ways around this problem?
No, that isn’t currently supported and would be a lot of work.
My suggestion would be: buffer data yourself using the async APIs, and then when you have the data, use something like a
MemoryStreamto deserialize…In my defence, I’m not aware of any other serializer that offers an async API here. In particular, when talking about slow/async streams, that usually means “network”: and you usually have the issue of “framing” to consider there; protobuf-net won’t know your framing requirements…