本文整理汇总了C#中Exchange.GetOrAdd方法的典型用法代码示例。如果您正苦于以下问题:C# Exchange.GetOrAdd方法的具体用法?C# Exchange.GetOrAdd怎么用?C# Exchange.GetOrAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exchange
的用法示例。
在下文中一共展示了Exchange.GetOrAdd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareReregistration
private void PrepareReregistration(Exchange exchange, Response response, Action<Request> reregister)
{
Int64 timeout = response.MaxAge * 1000 + _backoff;
ReregistrationContext ctx = exchange.GetOrAdd<ReregistrationContext>(
ReregistrationContextKey, _ => new ReregistrationContext(exchange, timeout, reregister));
if (log.IsDebugEnabled)
log.Debug("Scheduling re-registration in " + timeout + "ms for " + exchange.Request);
ctx.Restart();
}
示例2: PrepareRetransmission
private void PrepareRetransmission(Exchange exchange, Message msg, Action<TransmissionContext> retransmit)
{
TransmissionContext ctx = exchange.GetOrAdd<TransmissionContext>(
TransmissionContextKey, _ => new TransmissionContext(_config, exchange, msg, retransmit));
if (ctx.FailedTransmissionCount > 0)
{
ctx.CurrentTimeout = (Int32)(ctx.CurrentTimeout * _config.AckTimeoutScale);
}
else if (ctx.CurrentTimeout == 0)
{
ctx.CurrentTimeout = InitialTimeout(_config.AckTimeout, _config.AckRandomFactor);
}
if (log.IsDebugEnabled)
log.Debug("Send request, failed transmissions: " + ctx.FailedTransmissionCount);
ctx.Start();
}