public void ScheduleUpdateDataAsync(QueryQueueEntry key)
 {
     QueryQueueMutex.WaitOne();
     QueryQueue.Enqueue(key);
     QueryQueueMutex.ReleaseMutex();
     AnyOutstandingQuery.Signal();
 }
        public void ResetQueueAndCache()
        {
            QueryQueueMutex.WaitOne();
            for (; ;)
            {
                if (QueryQueue.Pop() == null)
                {
                    break;
                }
            }

            QueryQueueMutex.ReleaseMutex();
            lock (QueryCacheLock)
            {
                QueryCache.Clear();
            }
        }
        private void RunQueryThread()
        {
            for (; ;)
            {
                QueryQueueMutex.WaitOne();
                while (QueryQueue.IsEmpty() && !EndQueryThread)
                {
                    AnyOutstandingQuery.Wait(QueryQueueMutex);
                }

                if (EndQueryThread)
                {
                    QueryQueueMutex.ReleaseMutex();
                    break;
                }

                var sig = QueryQueue.Pop();
                QueryQueueMutex.ReleaseMutex();

                QueryAsyncToCacheAndUpdate(sig);
            }
        }