Esempio n. 1
0
        /// <summary>
        /// 读数据线程
        /// </summary>
        protected override void DoWork()
        {
            try
            {
                while (m_runFlag)
                {
                    while (m_kLineQueue.Count > 0)
                    {
                        USeKLine kLine = null;
                        m_kLineQueue.TryDequeue(out kLine);
                        Debug.Assert(kLine != null);

                        FileStorer storer = GetFileStorer(kLine);
                        try
                        {
                            storer.Write(ToKLineLog(kLine));
                            Interlocked.Increment(ref m_sotreCount);
                        }
                        catch (Exception ex)
                        {
                            Interlocked.Increment(ref m_errorStoreCount);
                            USeNotifyEventArgs arg = new USeNotifyEventArgs(USeNotifyLevel.Error, "文件保存K线失败," + ex.Message);
                            SafeRaiseNotifyEvent(this, arg);
                        }
                    }

                    Thread.Sleep(1000);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
        /// <summary>
        /// 读数据线程
        /// </summary>
        private void DoWork()
        {
            try
            {
                while (m_runFlag)
                {
                    while (m_marketDataQueue.Count > 0)
                    {
                        USeMarketData marketData = null;
                        m_marketDataQueue.TryDequeue(out marketData);
                        Debug.Assert(marketData != null);

                        FileStorer storer = GetFileStorer(marketData);
                        try
                        {
                            storer.Write(ToMarketDataLog(marketData));
                            Interlocked.Increment(ref m_sotreCount);
                        }
                        catch (Exception ex)
                        {
                            Interlocked.Increment(ref m_errorStoreCount);
                            USeNotifyEventArgs arg = new USeNotifyEventArgs(USeNotifyLevel.Error, "文件保存行情数据失败," + ex.Message);
                            SafeRaiseNotifyEvent(this, arg);
                        }
                    }

                    Thread.Sleep(1000);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }