I traced it down to RequestContext
via the .NET Reference Source. Apparently, the ChannelHandler.sendAsynchronously
field controls whether the message reply is done asynchronously (via RequestContext.BeginReply/EndReply
APM methods) or synchronously via RequestContext.Reply
.
As far as I can tell, all this does is frees a server-side thread which is returned to the pool, and which otherwise would be busy inside RequestContext.Reply
with "pumping" the stream to the client, for as long as the Stream
object is alive on the server.
This appears to be totally transparent, so I think you can safely use async
TAP-based contract methods and return Task<Stream>
. In another contract method you could do await Stream.WriteAsync
, for example.
Please share your actual experience as your own answer when you get there, I'd be very interested in the details :)