/// <summary> /// Shutdown the data queries and consolidation thread. /// </summary> public void Shutdown() { m_evtCancel.Set(); m_iquery.Close(); }
/// <summary> /// The query thread is where all data is collected from the underlying custom query managed. /// </summary> private void queryThread() { try { int nWait = 0; m_iquery.Open(); while (!m_evtCancel.WaitOne(nWait)) { if (!m_evtQueryEnabled.WaitOne(0)) { m_evtPaused.Set(); nWait = 250; continue; } m_evtPaused.Reset(); if (m_rgDataQueue.Count >= m_nMaxCount) { nWait = 10; continue; } double[] rgData = m_iquery.QueryByTime(m_dt, m_tsInc, m_nSegmentSize); if (rgData == null) { m_bQueryEnd = true; nWait = 10; continue; } nWait = 0; m_bQueryEnd = false; int nItemCount = rgData.Length / m_nSegmentSize; int nSrcIdx = 0; lock (m_objSync) { for (int i = 0; i < m_nSegmentSize; i++) { double[] rgItem = new double[nItemCount]; Array.Copy(rgData, nSrcIdx, rgItem, 0, nItemCount); nSrcIdx += nItemCount; m_rgDataQueue.Enqueue(rgItem); } } m_dt += TimeSpan.FromMilliseconds(m_nSegmentSize * m_tsInc.TotalMilliseconds); } } catch (Exception excpt) { throw excpt; } finally { m_iquery.Close(); } }