private void buttStart_Click(object sender, EventArgs e) { DoOnGuiThread(buttStart, () => { buttStart.Enabled = false; buttStop.Enabled = true; buttPause.Enabled = true; }); simulation.SimulateAsync((int)numReplicationsCount.Value, endTime - startTime); ChangeSimulationSpeed(); }
private void buttonRun_Click(object sender, System.EventArgs e) { try { NumberOfReplications = Int32.Parse(TextBoxReplications.Text); } catch (Exception ex) { MessageBox.Show("Enter a valid number of replications", "Invalid format", MessageBoxButtons.OK); return; } try { GeneratorSeed = Int32.Parse(textBoxSeed.Text); // simulation start int userSeed = 0; if (userSeed > 0 || textBoxSeed.Text != "") { Constants.Seed = userSeed; } else { Constants.Seed = 0; } } catch (Exception ex) { MessageBox.Show("Enter a valid generator seed", "Invalid format", MessageBoxButtons.OK); return; } _first = true; DisableChanges(); Sim = new MySimulation(); Sim.SetSimSpeed(_interval, _duration); Sim.AgentModelu.SelectedCars = SelectedCars; System.Action <MySimulation> updateGuiAction = new System.Action <MySimulation>((s) => UpdateGui(s)); System.Action <MySimulation> ReplicationFinished = new Action <MySimulation>((s) => UpdateUIAfterReplication()); System.Action <MySimulation> SimulationFinished = new Action <MySimulation>((s) => UpdateUIAfterSimulation()); Sim.OnReplicationDidFinish(simulation => simulation.InvokeAsync(UpdateUIAfterReplication)); Sim.OnSimulationDidFinish(simulation => simulation.InvokeAsync(UpdateUIAfterSimulation)); try { Sim.OnRefreshUI(s => this.Invoke(updateGuiAction, s)); } catch (Exception ex) { throw ex; } // 777 600 Sim.SimulateAsync(NumberOfReplications, 788400); DrawChart(); System.Action <MySimulation> enableChangesAction = new Action <MySimulation>((s) => EnableChanges()); // nefunguje //Sim.OnSimulationDidFinish(s => this.Invoke(enableChangesAction)); }