// HTTP channel could be accepted while there is no incoming request yet. The reply channel waits for the actual request.
// HTTP channel listeners do not accept more than one channel at a time.
DateTime start = DateTime.Now;
- accept_channel_handle.WaitOne (timeout - (DateTime.Now - start));
- accept_channel_handle.Reset ();
+ TimeSpan waitTimeout = timeout - (DateTime.Now - start);
+ if (waitTimeout.TotalMilliseconds > int.MaxValue)
+ waitTimeout = TimeSpan.FromMilliseconds (int.MaxValue);
+ accept_channel_handle.WaitOne (waitTimeout);
+ accept_channel_handle.Reset ();
TChannel ch = CreateChannel (timeout - (DateTime.Now - start));
ch.Closed += delegate {
accept_channel_handle.Set ();
lock (ce.RetrieverLock) {
var q = ce.ContextQueue;
if (q.Count == 0) {
- bool ret = ce.WaitHandle.WaitOne (timeout);
+ TimeSpan waitTimeout = timeout;
+ if (waitTimeout.TotalMilliseconds > int.MaxValue)
+ waitTimeout = TimeSpan.FromMilliseconds (int.MaxValue);
+ bool ret = ce.WaitHandle.WaitOne (waitTimeout);
return ret && TryDequeueRequest (channel, timeout - (DateTime.Now - start), out context); // recurse, am lazy :/
}
context = q.Dequeue ();