public virtual void Dispose()
{
if (IsDisposed)
{
return;
}
_status = ConsumerStatus.Disposing;
//NOTE: Wait all current running tasks to finish and after that dispose the objects
DateTime timeOut = DateTime.Now.AddSeconds(Global.ConsumerDisposeTimeoutInSeconds);
while (MessageInProgressCount() > 0 && DateTime.Now <= timeOut)
{
_watcher.InfoFormat("Wait for {0} messages in progress", MessageInProgressCount());
Thread.Sleep(1000);
}
_status = ConsumerStatus.Disposed;
_pool.Dispose();
CloseQueue();
}