private void RunSim(IProgress <string> progress, CancellationToken cancelToken) { // If the data type changes (ie from minutes to daily) we need to reset the // ticker store so the data for the ticker is of the correct type. We don't // want to store all types in memory because it will take up too much memory. if (Config.DataType != DataStore.DataType) { DataStore = new TickerDataStore(); DataStore.DataType = Config.DataType; } Sim = new Simulator(progress, cancelToken); // Create the simulator. if (Sim.CreateFromConfig(Config, DataStore)) { // Initializes all the instruments. Sim.Initialize(); // Runs the simulation. Sim.Run(); // Output all the data. Sim.Shutdown(); } // Free the memory. Sim = null; SystemSounds.Exclamation.Play(); }
private async void _clearCache_Click(object sender, RoutedEventArgs e) { EnableOptions(false); UpdateStatus("Start cleaning ticker cache"); await Task.Run(() => { DataStore.ClearCache(); DataStore = new TickerDataStore(); }); EnableOptions(true); UpdateStatus("Finished cleaning ticker cache"); }
public MainWindow() { InitializeComponent(); _shouldAutoRun = false; _shouldCloseAfterRun = false; _cancelToken = new CancellationTokenSource(); Config = new SimulatorConfig(); DataStore = new TickerDataStore(); _propertyGrid.SelectedObject = Config; InitFromCommandLine(); DataStore.DataType = Config.DataType; // If the command line option was to autorun, trigger the click for running. if (_shouldAutoRun == true) { StartSimRun(); } }