Exemplo n.º 1
0
        /// <summary>
        /// Runs the RateService Example which connects to the Rates Service for the specified number of seconds
        /// and terminates
        /// </summary>
        /// <param name="executeSeconds">The number of seconds to execute the Rate Service connection for</param>
        public void Run(int executeSeconds)
        {
            // Make the connection request to the Rates Service, this call creates the rates thread
            // which makes the connection to the Rates Service
            if (_rateService.Connect(_host, _port, _key) == true)
            {
                // We are not connected and authenticated until we get the "OnRateServiceConnected()"
                // event.  If we do not get this event we will get the "OnRateServiceFailed()" event.


                // Sleep the requested execute seconds
                Thread.Sleep(executeSeconds * 1000);

                // Finished so disconnect from the rates service
                _rateService.Disconnect();

                // Sleep a few seconds so we get the disconnect confirmation
                Thread.Sleep(3000);
            }
            else
            {
                Console.Out.WriteLine("RateServiceExample: Run Failed to connect to RateService");
            }
        }