/// <summary> /// Execute an order. /// </summary> /// <param name="message">A message containing an order.</param> public void ExecuteOrder(Message[] messages) { // We really can only add an order to the simulated broker's book from here. It will be executed sometime later by the broker simulator. foreach (Message message in messages) { BrokerSimulator.AddOrder(message); } }
/// <summary> /// Called when the service is stopped. /// </summary> protected override void OnStop() { try { // This shuts down the broker simulation when it is running. if (MarketSimulator.SimulatorParameters.IsExchangeSimulatorRunning) { BrokerSimulator.Stop(); } // This shuts down the price simulation when it is running. if (MarketSimulator.SimulatorParameters.IsPriceSimulatorRunning) { PriceSimulator.Stop(); } // Shut down each of the Web Services hosted by this Windows Service. foreach (ServiceHost serviceHost in this.serviceHosts) { serviceHost.Close(); } } catch (Exception exception) { // Any problems initializing should be sent to the Event Log. EventLog.WriteEntry(MarketSimulator.Source, String.Format("{0}: {1}", exception.Message, exception.StackTrace), EventLogEntryType.Information); } // Log the end of the service. try { EventLog.WriteEntry( MarketSimulator.Source, String.Format(Simulator.Properties.Resources.ServiceStopping, MarketSimulator.ServiceName), EventLogEntryType.Information); } catch (SecurityException) { } }