private void btnAdvanceBrainOne_Click(object sender, RoutedEventArgs e) { try { if (_links == null) { MessageBox.Show("There are no neural links", this.Title, MessageBoxButton.OK, MessageBoxImage.Warning); return; } NeuralBucket worker = new NeuralBucket(_links.Outputs.SelectMany(o => UtilityCore.Iterate(o.InternalLinks, o.ExternalLinks)).ToArray()); worker.Tick(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
private static void OperateBrain(NeuralBucket worker, CancellationToken cancel) { //NOTE: This method is running on an arbitrary thread try { while (!cancel.IsCancellationRequested) { worker.Tick(); } } catch (Exception) { // Don't leak errors, just go away } }