本文整理汇总了C#中System.Net.Connection.ResetStatistics方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.ResetStatistics方法的具体用法?C# Connection.ResetStatistics怎么用?C# Connection.ResetStatistics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Connection
的用法示例。
在下文中一共展示了Connection.ResetStatistics方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteBodyToConnection
public virtual void WriteBodyToConnection(Connection connection)
{
try
{
if (HasOnTransferProgress)
{
connection.OnBytesSent += HandleOnBytesSent;
connection.ResetStatistics();
}
switch (ContentSource)
{
case ContentSource.ContentBytes:
TriggerOnTransferStart(TransferDirection.Send, ContentBytes.Length);
connection.Send(ContentBytes);
TriggerOnTransferEnd(TransferDirection.Send);
break;
case ContentSource.ContentStream:
TriggerOnTransferStart(TransferDirection.Send, ContentStream.Length);
Byte[] lBuffer = new Byte[BUFFER_SIZE];
Int32 lBytesRead;
do
{
lBytesRead = ContentStream.Read(lBuffer, 0, BUFFER_SIZE);
if (lBytesRead != 0) connection.Send(lBuffer, 0, lBytesRead);
}
while (lBytesRead > 0);
if (CloseStream)
ContentStream.Close();
TriggerOnTransferEnd(TransferDirection.Send);
break;
case ContentSource.ContentNone:
// No action needed
break;
}
if (HasOnTransferProgress)
connection.OnBytesSent -= HandleOnBytesSent;
}
finally
{
fContentBytes = null;
fContentStream = null;
fContentString = null;
}
}