public void Clock_tick(object sender, EventArgs eArgs) { if (m_client == null) { return; } if (sender == m_clock) { // Check for messages Stack STK = new Stack(); foreach (string ourQueue in m_ourQueues.Keys) { STK.Push(ourQueue); } //foreach (string ourQueue in ourQueues.Keys) while (STK.Count > 0) { string ourQueue = (string)STK.Pop(); ulong headID = m_client.Increment(ourQueue, (ulong)0, (ulong)0); // null increment gets the value ulong lastQid = getLastReadID(ourQueue); // our internal count if (headID == lastQid) { continue; // we are up to date } processMessageHandler watcher = null; if (m_watchers.ContainsKey(ourQueue)) { watcher = (processMessageHandler)m_watchers[ourQueue]; } while (lastQid != headID) { string message = dequeue(ourQueue); if ((message == "") || (message == null)) { break; } // notify anybody interested if (watcher != null) { watcher(message); } lastQid = getLastReadID(ourQueue); // our internal count } } } }
public void registerWatcher(string queue, processMessageHandler w) { m_watchers[queue] = w; }