private TimeSpan GetPollingInterval() { switch (this.pollingMode) { case PollingMode.Idle: return(Ticks.ToTimeSpan(Ticks.FromTimeSpan(base.Settings.InactivityTimeout) / 2L)); case PollingMode.KeepAlive: return(WsrmUtilities.CalculateKeepAliveInterval(base.Settings.InactivityTimeout, base.Settings.MaxRetryCount)); case PollingMode.FastPolling: { TimeSpan span = WsrmUtilities.CalculateKeepAliveInterval(base.Settings.InactivityTimeout, base.Settings.MaxRetryCount); TimeSpan span2 = Ticks.ToTimeSpan(Ticks.FromTimeSpan(this.binder.DefaultSendTimeout) / 2L); if (span2 >= span) { return(span); } return(span2); } case PollingMode.NotPolling: return(TimeSpan.MaxValue); } throw Fx.AssertAndThrow("Unknown polling mode."); }
TimeSpan GetPollingInterval() { switch (this.pollingMode) { case PollingMode.Idle: return(Ticks.ToTimeSpan(Ticks.FromTimeSpan(this.Settings.InactivityTimeout) / 2)); case PollingMode.KeepAlive: return(WsrmUtilities.CalculateKeepAliveInterval(this.Settings.InactivityTimeout, this.Settings.MaxRetryCount)); case PollingMode.NotPolling: return(TimeSpan.MaxValue); case PollingMode.FastPolling: TimeSpan keepAliveInterval = WsrmUtilities.CalculateKeepAliveInterval(this.Settings.InactivityTimeout, this.Settings.MaxRetryCount); TimeSpan fastPollingInterval = Ticks.ToTimeSpan(Ticks.FromTimeSpan(this.binder.DefaultSendTimeout) / 2); if (fastPollingInterval < keepAliveInterval) { return(fastPollingInterval); } else { return(keepAliveInterval); } default: throw Fx.AssertAndThrow("Unknown polling mode."); } }
public static TimeSpan Divide(TimeSpan timeout, int factor) { if (timeout == TimeSpan.MaxValue) { return(TimeSpan.MaxValue); } return(Ticks.ToTimeSpan((Ticks.FromTimeSpan(timeout) / factor) + 1)); }
public static int ToMilliseconds(TimeSpan timeout) { if (timeout == TimeSpan.MaxValue) { return(Timeout.Infinite); } else { long ticks = Ticks.FromTimeSpan(timeout); if (ticks / TimeSpan.TicksPerMillisecond > int.MaxValue) { return(int.MaxValue); } return(Ticks.ToMilliseconds(ticks)); } }
// Socket.ReceiveTimeout/SendTimeout 0 means infinite/no-timeout. When dealing with cascading timeouts // if the remaining time reaches TimeSpan.Zero we don't want to turn off timeouts on the socket, instead // we want to use a very small timeout. private static int GetSocketTimeoutInMilliSeconds(TimeSpan timeout) { if (timeout == TimeSpan.MaxValue) { return(Timeout.Infinite); } if (timeout == TimeSpan.Zero) { // Socket.ReceiveTimeout/SendTimeout 0 means no timeout which is not what we want. // Use a small number instead return(1); } long ticks = Ticks.FromTimeSpan(timeout); return(ticks / TimeSpan.TicksPerMillisecond > int.MaxValue ? int.MaxValue : Ticks.ToMilliseconds(ticks)); }
public BufferedConnection(IConnection connection, TimeSpan flushTimeout, int writeBufferSize) : base(connection) { this.flushTimeout = Ticks.FromTimeSpan(flushTimeout); this.writeBufferSize = writeBufferSize; }
public static TimeSpan Add(TimeSpan timeout1, TimeSpan timeout2) { return(Ticks.ToTimeSpan(Ticks.Add(Ticks.FromTimeSpan(timeout1), Ticks.FromTimeSpan(timeout2)))); }
public static TimeSpan CalculateKeepAliveInterval(TimeSpan inactivityTimeout, int maxRetryCount) { return(Ticks.ToTimeSpan((Ticks.FromTimeSpan(inactivityTimeout) / 2L) / ((long)maxRetryCount))); }
public BufferedConnection(Microsoft.ServiceBus.Channels.IConnection connection, TimeSpan flushTimeout, int writeBufferSize) : base(connection) { this.flushTimeout = Ticks.FromTimeSpan(flushTimeout); this.writeBufferSize = writeBufferSize; }