protected virtual void InitializeDatafeed()
 {
     try
     {
         client = new TroyStevens.Market.Data.MarketDataConsumer(new InstanceContext(this), ProviderId);
         client.Open();
     }
     catch (Exception ex)
     {
         EndSession();
         throw ex;
     }
 }
 public void EndSessionNullArgumentTest(MarketDataConsumer client)
 {
     base.EndSession(client);
     Assert.Pass("These test method provide code coverage for the unit being tested.");
 }
        protected virtual void EndSession()
        {
            if (null == client)
                return;

            lock (synchObj)
            {
                try
                {
                    if (client.State == CommunicationState.Opened ||
                        client.State == CommunicationState.Opening)
                    {
                        client.EndSession();
                        client.Close();
                    }
                    else
                        client.Abort();
                }
                catch (Exception)
                {
                    client = null;
                }
                finally
                {
                    client = null;
                    if (!waitHandle.WaitOne(0))
                        waitHandle.Set();
                }
            }
        }
        protected void SessionClosedEvent()
        {
            client = null;

            if (null != _onAddComplete)
                _onAddComplete();

            if(null != _onNewSecurityTicksEvent)
            {
                SecurityTicksNoSkip value = null;
                if(securities.TryGetValue(Miscellaneous.END_OF_FEED, out value))
                    _onNewSecurityTicksEvent(value);

                if(securities.TryGetValue(Miscellaneous.INACTIVITY_TIMEOUT, out value))
                    _onNewSecurityTicksEvent(value);
            }

            UnRegisterSymbolTicksDelegates();

            if (!waitHandle.WaitOne(0))
                waitHandle.Set();
        }