本文整理汇总了C#中ITransport.Close方法的典型用法代码示例。如果您正苦于以下问题:C# ITransport.Close方法的具体用法?C# ITransport.Close怎么用?C# ITransport.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITransport
的用法示例。
在下文中一共展示了ITransport.Close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BufferedTransport
public BufferedTransport(IEasyGelfLogger logger, ITransport transport)
{
new Thread(() =>
{
var cancellationToken = cancellationTokenSource.Token;
try
{
GelfMessage mesage;
while (buffer.TryTake(out mesage, -1, cancellationToken))
{
try
{
transport.Send(mesage);
}
catch(Exception exception)
{
logger.Error("Cannot send message", exception);
}
}
}
catch
{
GelfMessage message;
while (buffer.TryTake(out message))
{
try
{
transport.Send(message);
}
catch (Exception exception)
{
logger.Error("Cannot send message", exception);
}
}
}
transport.Close();
stopEvent.Set();
}) {IsBackground = true, Name = "EasyGelf Buffered Transport Thread"}.Start();
}
示例2: PollingTransport
void IManager.OnTransportError(ITransport trans, string err)
{
(this as IManager).EmitError(SocketIOErrors.Internal, err);
if (trans.State == TransportStates.Connecting ||
trans.State == TransportStates.Opening)
{
#if !BESTHTTP_DISABLE_WEBSOCKET
if (trans is WebSocketTransport)
{
trans.Close();
// try to fall back
Transport = new PollingTransport(this);
Transport.Open();
}
else // fallback failed
#endif
(this as IManager).TryToReconnect();
}
else
{
trans.Close();
(this as IManager).TryToReconnect();
}
}