private void RefreshCriticalTables(RefreshEventArgs args) { try { HugoDataSet.AccountDataDataTable accountData = GetAccountData(ref m_accountsUpdateTime); HugoDataSet.CurrentPositionsDataTable currentPositions = GetCurrentPositions();; HugoDataSet.IndexWeightsDataTable indexWeights = GetIndexWeights(); HugoDataSet.TradingScheduleDataTable tradingSchedule = GetTradingSchedule(); lock (m_tableLock) { // if there are no changes, an empty table is returned by the above methods if (accountData.Count > 0) { if (AccountLimit > 0) { for (int i = accountData.Count - 1; i >= AccountLimit; i--) { accountData.Rows.RemoveAt(i); } } m_accountData = accountData; args.AccountsUpdated = true; } if (currentPositions.Count > 0) { m_currentPositions = currentPositions; args.PositionsUpdated = true; } if ((indexWeights.Count > 0) || (m_indexWeights == null)) { m_indexWeights = indexWeights; args.IndexWeightsUpdated = true; } if ((tradingSchedule.Count > 0) || (m_tradingSchedule == null)) { m_tradingSchedule = tradingSchedule; args.TradingScheduleUpdated = true; } } } catch (Exception ex) { Error("Unable to refresh critical data tables", ex); } }
private void Dispose(bool disposing) { if (disposing) { StopMonitor(); if (m_tableAdapters != null) { foreach (IHugoTableAdapter tableAdapter in m_tableAdapters) { if (tableAdapter != null) { tableAdapter.Dispose(); } } m_tableAdapters = null; } if (m_currentPositions != null) { m_currentPositions.Dispose(); m_currentPositions = null; } if (m_trades != null) { m_trades.Dispose(); m_trades = null; } if (m_accountData != null) { m_accountData.Dispose(); m_accountData = null; } if (m_indexWeights != null) { m_indexWeights.Dispose(); m_indexWeights = null; } if (m_tradingSchedule != null) { m_tradingSchedule.Dispose(); m_tradingSchedule = null; } Info("PositionMonitorUtilities disposed"); } }