本文整理汇总了C#中OutputStream.AddFlowControlCredit方法的典型用法代码示例。如果您正苦于以下问题:C# OutputStream.AddFlowControlCredit方法的具体用法?C# OutputStream.AddFlowControlCredit怎么用?C# OutputStream.AddFlowControlCredit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputStream
的用法示例。
在下文中一共展示了OutputStream.AddFlowControlCredit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteMoreDataThanCredited_OnlyCreditedDataWritten
public void WriteMoreDataThanCredited_OnlyCreditedDataWritten()
{
using (Stream transport = new QueueStream())
using (WriteQueue queue = new WriteQueue(transport))
{
Task pumpTask = queue.PumpToStreamAsync();
OutputStream output = new OutputStream(1, Framing.Priority.Pri1, queue);
FrameReader reader = new FrameReader(transport, false, CancellationToken.None);
int dataLength = 0x1FFFF; // More than the 0x10000 default
Task writeTask = output.WriteAsync(new byte[dataLength], 0, dataLength);
Assert.False(writeTask.IsCompleted);
Frame frame = reader.ReadFrameAsync().Result;
Assert.False(frame.IsControl);
Assert.Equal(0x10000, frame.FrameLength);
Task<Frame> nextFrameTask = reader.ReadFrameAsync();
Assert.False(nextFrameTask.IsCompleted);
// Free up some space
output.AddFlowControlCredit(10);
frame = nextFrameTask.Result;
Assert.False(frame.IsControl);
Assert.Equal(10, frame.FrameLength);
nextFrameTask = reader.ReadFrameAsync();
Assert.False(nextFrameTask.IsCompleted);
}
}