流式服务的示例合约:
public interface IFileService
{
Stream Download(int id);
}
示例客户:
var proxy = ...
using(var responseStream = proxy.Download(666))
{
while(true)
{
var someBytes = //responseStream.Read(...)
if(someBytes[0] == 11)
return;//here is called dispose by using statement, but stream will call Read in it's Dispose method!
}
}
所以,是的,如果你决定从你的10GB文件的开始只分析几个字节并离开这一点 - 你将注定要等到WCF CloseTimeout到期,或者直到你读完整个10GB文件,根据{ {3}}。
如何告诉WCF停止阅读整个流而没有“zerofying” closeTimeout 选项的廉价技巧?