protected override void OnGUIBoxPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { CGUIBox GUIBox = (CGUIBox)sender; if (e.PropertyName == "IsFORTSOnline") { FORTSBGColor = GenColorOKOrAlarm(GUIBox.IsFORTSOnline); } else if (e.PropertyName == "IsSessionActive") { string status = ""; if (GUIBox.IsSessionActive == true) { status = "Актив"; } else { status = "Неактив"; } //TO DO normal GUIDispatcher.BeginInvoke(new Action(() => m_mainWindow.SessionTable.SessionStatusText.TextValue = status)); } // GUIDispatcher.Invoke(new Action(() => m_mainWindow.SessionTable.SessionStatusText.TextBlockLabel.Text = "Act")); }
private void ProcessBlockingQueue(string threadName, ref CBlockingQueue <Action> blockingQueue, int countLimit, bool bOutAlarm, int secRepeatAlarm = 20) { DateTime lastAlarm = new DateTime(0); while (true) { Action act = blockingQueue.GetElementBlocking(); if (blockingQueue.Count > countLimit) { if ((DateTime.Now - lastAlarm).TotalSeconds > secRepeatAlarm && bOutAlarm) { //2018-04-15 removed to make cleaner alarm list/file //Error(threadName+ "quee more than max skip messages. Count="+blockingQueue.Count); lastAlarm = DateTime.Now; } } else if (GUIDispatcher != null) { GUIDispatcher.BeginInvoke(act); } } }
//This thread not removes //deals from queue public void ThreadWindowsUpdate() { while (true) { Action value = m_bqActions.GetElementBlocking(); while (GUIDispatcher == null) { System.Threading.Thread.Sleep(100); } GUIDispatcher.BeginInvoke(value, DispatcherPriority.Normal, null); } }
/// <summary> /// Call from: /// /// ThreadDataReciever /// </summary> private void ProcessStocks() { var dictStockClass = _dataReciever.OutpStockClass[_tickerName]; if (dictStockClass.LstStockConf == null) { return; //get out } lock (_lstStockConf) { _lstStockConf.Clear(); dictStockClass.LstStockConf.ForEach(el => _lstStockConf.Add(el)); } var stockConf = dictStockClass.LstStockConf.Find(el => el.MinStep == (decimal)Step); if (stockConf == null) { return; //get out } int prec = stockConf.PrecissionNum; //process stocks if (dictStockClass.StockListAsks != null && dictStockClass.StockListBids != null) { lock (_dataReciever.OutpStockClass) { lock (dictStockClass.Locker) { try { bool bStockChanged = false; if (dictStockClass.StockListAsks.ContainsKey(prec)) { List <CStock> asks = dictStockClass.StockListAsks[prec]; if (asks != null) { for (int i = 0; i < Asks.Length; i++) { if (i >= asks.Count) { Asks[i].Price = 0; Asks[i].Amount = 0; continue; } if (Asks[i].Price != (double)asks[i].Price || Asks[i].Amount != (int)asks[i].Volume ) { Asks[i].Price = (double)asks[i].Price; Asks[i].Amount = (int)asks[i].Volume; bStockChanged = true; //debugging // if (Bids[0].Price!=0 &&Asks[i].Price <= Bids[0].Price) // Thread.Sleep(0); } } //2018-07-09 } } if (dictStockClass.StockListBids.ContainsKey(prec)) { List <CStock> bids = dictStockClass.StockListBids[prec]; if (bids != null) { for (int i = 0; i < Bids.Length; i++) { if (i >= bids.Count) { Bids[i].Price = 0; Bids[i].Amount = 0; continue; } if (Bids[i].Price != (double)bids[i].Price || Bids[i].Amount != (int)bids[i].Volume) { Bids[i].Price = (double)bids[i].Price; Bids[i].Amount = (int)bids[i].Volume; bStockChanged = true; //if (Asks[0].Price!=0 && Bids[i].Price >= Asks[0].Price) // Thread.Sleep(0); } } } } /* * for (int k = 0; k < Asks.Length; k++) * { * * * if (Bids[0].Price!=0 && Asks[k].Price!=0 && Asks[k].Price <= Bids[0].Price) * Thread.Sleep(0); * } * * for (int j = 0; j < Bids.Length; j++) * { * * * if ((Asks[0].Price != 0) && (Bids[j].Price >= Asks[0].Price)) * Thread.Sleep(0); * } */ if (bStockChanged) { _vmUserPos.Recalc((double)Bids[0].Price, (double)Asks[0].Price, Step, Decimals); ForceRepaintControlStock(); GUIDispatcher.BeginInvoke(new Action(() => { try { //note: put it here because of synchronizing problems (pforit calc on graphics is faster !) } catch (Exception e) { Error("MarketViewModel process stocks GUI", e); } } )); } } catch (Exception e) { Error("", e); } // else // Thread.Sleep(0); } } } }