protected virtual void EvaluationThread(object s, DoWorkEventArgs args) { //Get our entry points (elements with nothing connected to output) List <dynNodeModel> topElements = DynamoViewModel.Model.HomeSpace.GetTopMostNodes().ToList(); //Mark the topmost as dirty/clean foreach (dynNodeModel topMost in topElements) { topMost.MarkDirty(); } //TODO: Flesh out error handling try { var topNode = new BeginNode(new List <string>()); int i = 0; var buildDict = new Dictionary <dynNodeModel, Dictionary <int, INode> >(); foreach (dynNodeModel topMost in topElements) { string inputName = i.ToString(); topNode.AddInput(inputName); topNode.ConnectInput(inputName, topMost.BuildExpression(buildDict)); i++; DynamoLogger.Instance.Log(topMost); } FScheme.Expression runningExpression = topNode.Compile(); Run(topElements, runningExpression); // inform any objects that a run has happened DynamoLogger.Instance.Log(runningExpression); } catch (CancelEvaluationException ex) { /* Evaluation was cancelled */ OnRunCancelled(false); //this.CancelRun = false; //Reset cancel flag RunCancelled = false; //If we are forcing this, then make sure we don't run again either. if (ex.Force) { runAgain = false; } OnRunCompleted(this, false); } catch (Exception ex) { /* Evaluation has an error */ //Catch unhandled exception if (ex.Message.Length > 0) { DynamoLogger.Instance.Log(ex); } OnRunCancelled(true); //Reset the flags runAgain = false; RunCancelled = false; OnRunCompleted(this, false); if (Testing) { Assert.Fail(ex.Message + ":" + ex.StackTrace); } } finally { /* Post-evaluation cleanup */ DynamoViewModel.RunEnabled = true; //No longer running Running = false; foreach (FunctionDefinition def in dynSettings.FunctionWasEvaluated) { def.RequiresRecalc = false; } //If we should run again... if (runAgain) { //DynamoLogger.Instance.Log("Running again."); //Reset flag runAgain = false; RunExpression(_showErrors); } else { //DynamoLogger.Instance.Log("Run completed."); OnRunCompleted(this, true); } } }
protected virtual void EvaluationThread(object s, DoWorkEventArgs args) { var sw = new Stopwatch(); sw.Start(); //Get our entry points (elements with nothing connected to output) List<NodeModel> topElements = DynamoViewModel.Model.HomeSpace.GetTopMostNodes().ToList(); //Mark the topmost as dirty/clean foreach (NodeModel topMost in topElements) { /* AstBuilder builder = AstBuilder.Instance; topMost.CompileToAstNode(builder); builder.Execute(); */ topMost.MarkDirty(); } try { var topNode = new BeginNode(new List<string>()); int i = 0; var buildDict = new Dictionary<NodeModel, Dictionary<int, INode>>(); foreach (NodeModel topMost in topElements) { string inputName = i.ToString(); topNode.AddInput(inputName); topNode.ConnectInput(inputName, topMost.BuildExpression(buildDict)); i++; //DynamoLogger.Instance.Log(topMost); } FScheme.Expression runningExpression = topNode.Compile(); Run(topElements, runningExpression); // inform any objects that a run has happened //DynamoLogger.Instance.Log(runningExpression); } catch (CancelEvaluationException ex) { /* Evaluation was cancelled */ OnRunCancelled(false); //this.CancelRun = false; //Reset cancel flag RunCancelled = false; //If we are forcing this, then make sure we don't run again either. if (ex.Force) runAgain = false; OnRunCompleted(this, false); } catch (Exception ex) { /* Evaluation has an error */ //Catch unhandled exception if (ex.Message.Length > 0) { DynamoLogger.Instance.Log(ex); } OnRunCancelled(true); //Reset the flags runAgain = false; RunCancelled = false; OnRunCompleted(this, false); if (Testing) Assert.Fail(ex.Message + ":" + ex.StackTrace); } finally { /* Post-evaluation cleanup */ DynamoViewModel.RunEnabled = true; //No longer running Running = false; foreach (FunctionDefinition def in dynSettings.FunctionWasEvaluated) def.RequiresRecalc = false; //If we should run again... if (runAgain) { //Reset flag runAgain = false; RunExpression(_showErrors); } else { OnRunCompleted(this, true); } sw.Stop(); DynamoLogger.Instance.Log(string.Format("Evaluation completed in {0}", sw.Elapsed.ToString())); } }
protected virtual void EvaluationThread(object s, DoWorkEventArgs args) { /* Execution Thread */ //Get our entry points (elements with nothing connected to output) IEnumerable<dynNodeModel> topElements = DynamoModel.HomeSpace.GetTopMostNodes(); //Mark the topmost as dirty/clean foreach (dynNodeModel topMost in topElements) topMost.MarkDirty(); //TODO: Flesh out error handling try { var topNode = new BeginNode(new List<string>()); int i = 0; var buildDict = new Dictionary<dynNodeModel, Dictionary<int, INode>>(); foreach (dynNodeModel topMost in topElements) { string inputName = i.ToString(); topNode.AddInput(inputName); topNode.ConnectInput(inputName, topMost.BuildExpression(buildDict)); i++; } FScheme.Expression runningExpression = topNode.Compile(); Run(DynamoModel.RunInDebug, topElements, runningExpression); } catch (CancelEvaluationException ex) { /* Evaluation was cancelled */ OnRunCancelled(false); //this.CancelRun = false; //Reset cancel flag RunCancelled = true; //If we are forcing this, then make sure we don't run again either. if (ex.Force) runAgain = false; OnRunCompleted(this, false); } catch (Exception ex) { /* Evaluation has an error */ //Catch unhandled exception if (ex.Message.Length > 0) { dynSettings.Controller.DynamoViewModel.Log(ex); } OnRunCancelled(true); //Reset the flags runAgain = false; RunCancelled = true; OnRunCompleted(this, false); } finally { /* Post-evaluation cleanup */ //Re-enable run button //dynSettings.Bench.Dispatcher.Invoke(new Action( // delegate // { // dynSettings.Bench.RunButton.IsEnabled = true; // } //)); DynamoModel.RunEnabled = true; //No longer running Running = false; foreach (FunctionDefinition def in dynSettings.FunctionWasEvaluated) def.RequiresRecalc = false; //If we should run again... if (runAgain) { //Reset flag runAgain = false; if (dynSettings.Bench != null) { //Run this method again from the main thread dynSettings.Bench.Dispatcher.BeginInvoke(new Action( delegate { RunExpression(_showErrors); } )); } } else { OnRunCompleted(this, true); } } }
protected virtual void EvaluationThread(object s, DoWorkEventArgs args) { /* Execution Thread */ //Get our entry points (elements with nothing connected to output) IEnumerable <dynNodeModel> topElements = DynamoModel.HomeSpace.GetTopMostNodes(); //Mark the topmost as dirty/clean foreach (dynNodeModel topMost in topElements) { topMost.MarkDirty(); } //TODO: Flesh out error handling try { var topNode = new BeginNode(new List <string>()); var buildDict = new Dictionary <dynNodeModel, Dictionary <int, INode> >(); foreach (var topMost in topElements.Select((node, index) => new { node, index })) { string inputName = topMost.index.ToString(); topNode.AddInput(inputName); topNode.ConnectInput(inputName, topMost.node.BuildExpression(buildDict)); } FScheme.Expression runningExpression = topNode.Compile(); Run(DynamoModel.RunInDebug, topElements, runningExpression); } catch (CancelEvaluationException ex) { /* Evaluation was cancelled */ OnRunCancelled(false); //this.CancelRun = false; //Reset cancel flag RunCancelled = true; //If we are forcing this, then make sure we don't run again either. if (ex.Force) { runAgain = false; } OnRunCompleted(this, false); } catch (Exception ex) { /* Evaluation has an error */ //Catch unhandled exception if (ex.Message.Length > 0) { dynSettings.Controller.DynamoViewModel.Log(ex); } OnRunCancelled(true); //Reset the flags runAgain = false; RunCancelled = true; OnRunCompleted(this, false); } finally { /* Post-evaluation cleanup */ DynamoModel.RunEnabled = true; //No longer running Running = false; foreach (FunctionDefinition def in dynSettings.FunctionWasEvaluated) { def.RequiresRecalc = false; } //If we should run again... if (runAgain) { //Reset flag runAgain = false; if (dynSettings.Bench != null) { //Run this method again from the main thread dynSettings.Bench.Dispatcher.BeginInvoke( new Action(() => RunExpression(_showErrors))); } } else { OnRunCompleted(this, true); } } }
protected virtual void EvaluationThread(object s, DoWorkEventArgs args) { /* Execution Thread */ //Get our entry points (elements with nothing connected to output) var topElements = homeSpace.GetTopMostNodes(); //Mark the topmost as dirty/clean foreach (var topMost in topElements) topMost.MarkDirty(); //TODO: Flesh out error handling try { var topNode = new BeginNode(new List<string>()); var i = 0; var buildDict = new Dictionary<dynNode, Dictionary<int, INode>>(); foreach (var topMost in topElements) { var inputName = i.ToString(); topNode.AddInput(inputName); topNode.ConnectInput(inputName, topMost.BuildExpression(buildDict)); i++; } Expression runningExpression = topNode.Compile(); Run(topElements, runningExpression); } catch (CancelEvaluationException ex) { /* Evaluation was cancelled */ OnRunCancelled(false); //this.CancelRun = false; //Reset cancel flag this.RunCancelled = true; //If we are forcing this, then make sure we don't run again either. if (ex.Force) this.runAgain = false; } catch (Exception ex) { /* Evaluation has an error */ //Catch unhandled exception if (ex.Message.Length > 0) { Bench.Dispatcher.Invoke(new Action( delegate { Bench.Log(ex); } )); } OnRunCancelled(true); //Reset the flags this.runAgain = false; this.RunCancelled = true; } finally { /* Post-evaluation cleanup */ //Re-enable run button Bench.Dispatcher.Invoke(new Action( delegate { Bench.RunButton.IsEnabled = true; } )); //No longer running this.Running = false; //If we should run again... if (this.runAgain) { //Reset flag this.runAgain = false; //Run this method again from the main thread Bench.Dispatcher.BeginInvoke(new Action( delegate { RunExpression(_debug, _showErrors); } )); } } }