示例#1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MBTradingConnectionManager(MBTradingAdapter adapter)
        {
            ChangeOperationalState(OperationalStateEnum.Constructed);

            _adapter             = adapter;
            _messageLoopOperator = new BackgroundMessageLoopOperator(false);
            _quotes  = new MBTradingQuote(_messageLoopOperator);
            _history = new MBTradingHistory(_messageLoopOperator);
            _orders  = new MBTradingOrders(_messageLoopOperator);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public MBTradingConnectionManager(MBTradingAdapter adapter)
        {
            ChangeOperationalState(OperationalStateEnum.Constructed);

            _adapter = adapter;
            _messageLoopOperator = new BackgroundMessageLoopOperator(false);
            _quotes = new MBTradingQuote(_messageLoopOperator);
            _history = new MBTradingHistory(_messageLoopOperator);
            _orders = new MBTradingOrders(_messageLoopOperator);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        public void Dispose()
        {
            try
            {
                lock (this)
                {
                    if (_quotes != null)
                    {
                        _quotes.Dispose();
                        _quotes = null;
                    }

                    if (_history != null)
                    {
                        _history.Dispose();
                        _history = null;
                    }

                    if (_orders != null)
                    {
                        _orders.UnInitialize();
                        _orders.Dispose();
                        _orders = null;
                    }

                    if (_adapter != null)
                    {
                        _adapter = null;
                    }

                    if (_communicationManager != null)
                    {
                        _communicationManager.OnLogonSucceed -= new IMbtComMgrEvents_OnLogonSucceedEventHandler(_communicationManager_OnLogonSucceed);
                        _communicationManager = null;
                    }

                    if (_messageLoopOperator != null)
                    {
                        _messageLoopOperator.Stop();
                        _messageLoopOperator.Dispose();
                        _messageLoopOperator = null;
                    }

                    ChangeOperationalState(OperationalStateEnum.Disposed);
                }
            }
            catch (Exception ex)
            {
                SystemMonitor.OperationError(ex.Message);
            }

            //GC.Collect();
        }
        /// <summary>
        /// 
        /// </summary>
        public void Dispose()
        {
            try
            {
                lock (this)
                {
                    if (_quotes != null)
                    {
                        _quotes.Dispose();
                        _quotes = null;
                    }

                    if (_history != null)
                    {
                        _history.Dispose();
                        _history = null;
                    }

                    if (_orders != null)
                    {
                        _orders.UnInitialize();
                        _orders.Dispose();
                        _orders = null;
                    }

                    if (_adapter != null)
                    {
                        _adapter = null;
                    }

                    if (_communicationManager != null)
                    {
                        _communicationManager.OnLogonSucceed -= new IMbtComMgrEvents_OnLogonSucceedEventHandler(_communicationManager_OnLogonSucceed);
                        _communicationManager = null;
                    }

                    if (_messageLoopOperator != null)
                    {
                        _messageLoopOperator.Stop();
                        _messageLoopOperator.Dispose();
                        _messageLoopOperator = null;
                    }

                    ChangeOperationalState(OperationalStateEnum.Disposed);
                }
            }
            catch (Exception ex)
            {
                SystemMonitor.OperationError(ex.Message);
            }

            //GC.Collect();
        }