private void executeDataUpdate() { while (!AllStop) { lock (lock_select) if (selectedName != "" && selected) { string coinName = selectedName; Ticker tempTicker; List <Account> tempAccount; lock (((Main)Owner).lock_mainUpdater) { tempTicker = ((Main)Owner).ticker[coinName]; tempAccount = new List <Account>(((Main)Owner).account); } JArray tempTH = react.getTransactionData(coinName); List <double>[] tempOB = react.getOrderBookData(coinName); lock (lock_updater) { bool isHold = false; ticker = tempTicker; for (int i = 0; i < tempAccount.Count; i++) { if (tempAccount[i].coinName == "KRW") { account[0].coinName = tempAccount[i].coinName; account[0].locked = tempAccount[i].locked; account[0].valid = tempAccount[i].valid; } else if (tempAccount[i].coinName == coinName) { isHold = true; account[1].coinName = tempAccount[i].coinName; account[1].locked = tempAccount[i].locked; account[1].valid = tempAccount[i].valid; break; } } if (!isHold) { account[1].coinName = coinName; account[1].locked = 0; account[1].valid = 0; } transaction = tempTH; ob = tempOB; if (ob != null) { THMax = double.MinValue; for (int i = 0; i < 15; i++) { THMax = Math.Max(THMax, tempOB[2][i]); THMax = Math.Max(THMax, tempOB[3][i]); } } if (needTradeInit) { needTradeInit = false; needTradeUpdate = true; } } } for (int i = 0; !AllStop && !needTradeInit && i < 10; i++) { Thread.Sleep(100); } } }
private void executeDataUpdate() { while (!AllStop) { lock (lock_select) if (selectedName != "" && selected) { string name = selectedName; bool[] isNeedUpdate = { false, false, false, false }; double[] tempTickerData = null; JArray tempTHData = null; List <double>[] tempOBData = null; double tempTHMax = double.MinValue; double[] tempBalacneData = null; if (selected) { tempTickerData = react.getTickerData(name); if (tempTickerData != null) { isNeedUpdate[0] = true; } else { selected = false; } } if (selected) { tempTHData = react.getTransactionData(name); if (tempTHData != null) { isNeedUpdate[1] = true; } else { selected = false; } } if (selected) { tempOBData = react.getOrderBookData(name); if (tempOBData != null) { for (int i = 0; i < 15; i++) { tempTHMax = Math.Max(tempTHMax, tempOBData[2][i]); tempTHMax = Math.Max(tempTHMax, tempOBData[3][i]); } isNeedUpdate[2] = true; } else { selected = false; } } if (needTradeInit) { tempBalacneData = react.getBalanceData(name); if (tempBalacneData != null) { isNeedUpdate[3] = true; needTradeInit = false; } } if (selected) { lock (lock_updater) { if (isNeedUpdate[0]) { for (int i = 0; i < 11; i++) { tickerData[i] = tempTickerData[i]; } } if (isNeedUpdate[1]) { transactionData = tempTHData; } if (isNeedUpdate[2]) { ob = tempOBData; THMax = tempTHMax; } if (isNeedUpdate[3]) { for (int i = 0; i < 7; i++) { vbalanceData[i] = tempBalacneData[i]; } vbalanceData[6] = tickerData[1]; needTradeUpdate = true; } } } } for (int i = 0; i < 10; i++) { if (AllStop || needTradeInit) { break; } Thread.Sleep(100); } } }