コード例 #1
0
        /// <summary>
        /// Thread gets market data from DataRecieve
        /// and copy it to the MarketViewModel
        /// </summary>
        private void ThreadDataReciever()
        {
            CCommunicator communicator = _kernelTerminal.Communicator;



            while (IsAlive)
            {
                try
                {
                    //whait till data is available
                    while (IsDataUnavailable(_dataReciever))
                    {
                        _dataReciever = communicator.GetDataReciever(ConnId);
                        Thread.Sleep(100);

                        if (!IsAlive)
                        {
                            return;
                        }
                    }
                    DateTime dtBegin = DateTime.Now;
                    ProcessStocks();
                    ProcessAggrDeals();
                    ProcessRowDeals();


                    int parSleep = GetParSleepBeetwenStockUpd();



                    //  int minSleePeriod = 50;


                    double dt = parSleep - (DateTime.Now - dtBegin).TotalMilliseconds;
                    //  dt = Math.Max(dt,minSleePeriod);

                    if (dt > 0)
                    {
                        Thread.Sleep((int)dt);
                    }
                }

                catch (Exception e)
                {
                    Error("MarketViewModel.ThreadDataReciever", e);
                }
            }


            IsDead = true;
        }
コード例 #2
0
        private bool IsDataUnavailable(CDataReciever dataReciever)
        {
            if (dataReciever == null || _tickerName == null ||
                !dataReciever.OutpStockClass.ContainsKey(_tickerName) ||
                !dataReciever.OutpListAggrDeals.ContainsKey(_tickerName) ||
                !dataReciever.OutpListRawDeals.ContainsKey(_tickerName))
            {
                return(true);
            }


            return(false);
        }