Esempio n. 1
0
        /// <summary>
        /// Executed when the Replay/Stop button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnReplay_Click(object sender, EventArgs e)
        {
            if (_replayFeed == null)
            {
                //Start new replay using specified file name
                _replayFeed = new ApiEventFeedReplay(txtFileName.Text);
                string securitySymbol = System.IO.Path.GetFileName(txtFileName.Text).Substring(0, 3);

                //Create stock to process events
                _security = new Security(securitySymbol);
                _replayFeed.AddSecurity(_security);
                securityMarketView.Security = _security;

                //Initiate replay on separate thread
                _replayThread = new Thread(_replayFeed.Execute);
                _replayThread.Start();

                //Update GUI controls
                btnPause.Enabled = true;
                btnReplay.Text   = "Stop";
                ReplayToolTips.SetToolTip(btnReplay, "Stop replay");
            }
            else
            {
                //Stop replay
                Stop();

                //Update GUI controls
                btnPause.Enabled = false;
                btnReplay.Text   = "Replay";
                ReplayToolTips.SetToolTip(btnReplay, "Start replay");
                btnPause_Click(this, null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Stops event feed updates and closes down feed and thread
        /// </summary>
        private void Stop()
        {
            if (_replayFeed != null)
            {
                _replayFeed.RemoveSecurity(_security);
                Application.DoEvents();
                _replayThread.Abort();

                while (_replayThread.ThreadState != ThreadState.Aborted)
                {
                    Thread.Sleep(100);
                }
                _replayThread = null;
                _replayFeed   = null;
            }
        }