public void StopSimulation() { if (aThread == null) { return; } if (buttonSimulation.InvokeRequired) { StopSimulationCallback ea = new StopSimulationCallback(StopSimulation); BeginInvoke(ea); } else { // actually stop the rendering: lock ( progress ) { progress.Continue = false; } aThread.Join(); aThread = null; // GUI stuff: SimModeGUI(false); } }
protected void StopSimulation() { if (sim == null || aThread == null) { return; } if (buttonStart.InvokeRequired) { StopSimulationCallback ea = new StopSimulationCallback(StopSimulation); BeginInvoke(ea); } else { // actually stop the simulation thread: cont = false; aThread.Join(); aThread = null; // GUI stuff: buttonStart.Enabled = true; buttonReset.Enabled = true; buttonStop.Enabled = false; } }