private void EventLoop()
{
Trio<Delegate, object[], AsyncResult> eventDelegate;
while (true)
{
if (this.shouldStop)
break;
if (this.queue.TryDequeue(BLOCK_TIME_MILLIS, out eventDelegate))
{
// invoke the delegate on this thread
try { eventDelegate.Item1.DynamicInvoke(eventDelegate.Item2); }
catch (Exception) { }
// fire the completed event
eventDelegate.Item3.OnComplete.Set();
}
}
// cleanup
foreach (var mre in this.cache)
mre.Dispose();
}