private void EngineLoop() { Stopwatch sw = new Stopwatch(); while (true) { if (theNeuronArray == null) { engineIsWaiting = true; Thread.Sleep(100); } else if (engineDelay > 1000) { engineIsWaiting = true; if (updateDisplay) { Application.Current.Dispatcher.Invoke((Action) delegate { label.Content = "Not Running " + theNeuronArray.Generation.ToString("N0"); }); updateDisplay = false; displayUpdateTimer.Start(); } Thread.Sleep(100); //check the engineDelay every 100 ms. } else { engineIsWaiting = false; if (theNeuronArray != null) { sw.Reset(); sw.Start(); theNeuronArray.Fire(); sw.Stop(); engineElapsed = sw.ElapsedMilliseconds; if (updateDisplay) { Application.Current.Dispatcher.Invoke((Action) delegate { label.Content = "Running, Speed: " + slider.Value + " " + theNeuronArray.Generation.ToString("N0"); theNeuronArrayView.UpdateNeuronColors(); }); updateDisplay = false; displayUpdateTimer.Start(); } } Thread.Sleep(Math.Abs(engineDelay)); } } }
private void EngineLoop() { while (true) { if (theNeuronArray == null) { engineIsWaiting = true; Thread.Sleep(100); } else if (engineDelay > 1000) { engineIsWaiting = true; if (updateDisplay) { Application.Current.Dispatcher.Invoke((Action) delegate { label.Content = "Not Running " + theNeuronArray.Generation.ToString("N0"); }); updateDisplay = false; displayUpdateTimer.Start(); } Thread.Sleep(100); //check the engineDelay every 100 ms. } else { engineIsWaiting = false; if (theNeuronArray != null) { Utils.GetSystemTimePreciseAsFileTime(out long startTime); theNeuronArray.Fire(); Utils.GetSystemTimePreciseAsFileTime(out long end); engineElapsed = end - startTime; if (updateDisplay) { Application.Current.Dispatcher.Invoke((Action) delegate { label.Content = "Running, Speed: " + slider.Value + " " + theNeuronArray.Generation.ToString("N0"); theNeuronArrayView.UpdateNeuronColors(); }); updateDisplay = false; displayUpdateTimer.Start(); } } Thread.Sleep(Math.Abs(engineDelay)); } } }
private void EngineLoop() { while (true) { if (theNeuronArray == null) { Thread.Sleep(100); } else if (engineDelay > 1000) { engineIsPaused = true; if (updateDisplay) { Application.Current.Dispatcher.Invoke((Action) delegate { labelEngineStatus.Content = "Not Running Cycle: " + theNeuronArray.Generation.ToString("N0"); }); updateDisplay = false; displayUpdateTimer.Start(); } Thread.Sleep(100); //check the engineDelay every 100 ms. } else { engineIsPaused = false; if (theNeuronArray != null) { long start = Utils.GetPreciseTime(); theNeuronArray.Fire(); long end = Utils.GetPreciseTime(); engineElapsed = end - start; if (updateDisplay) { Application.Current.Dispatcher.Invoke((Action) delegate { long dStart = Utils.GetPreciseTime(); theNeuronArrayView.UpdateNeuronColors(); long dEnd = Utils.GetPreciseTime(); displayElapsed = dEnd - dStart; }); updateDisplay = false; displayUpdateTimer.Start(); } } Thread.Sleep(Math.Abs(engineDelay)); } } }
private static void EngineLoop() { while (true) { if (engineDelay > 1000) { engineIsWaiting = true; Thread.Sleep(100); //check the engineDelay every 100 ms. } else { engineIsWaiting = false; if (theNeuronArray != null) { theNeuronArray.Fire(); } Thread.Sleep(Math.Abs(engineDelay)); } } }