Ejemplo n.º 1
0
        /// <summary>
        /// This method is typically called from the main application thread (as
        /// a result of user actions such as button click or node UI changes) to
        /// schedule an update of the graph. This call may or may not represent
        /// an actual update. In the event that the user action does not result
        /// in actual graph update (e.g. moving of node on UI), the update task
        /// will not be scheduled for execution.
        /// </summary>
        public void Run()
        {
            var traceData = PreloadedTraceData;

            if ((traceData != null) && traceData.Any())
            {
                // If we do have preloaded trace data, set it here first.
                var setTraceDataTask = new SetTraceDataAsyncTask(scheduler);
                if (setTraceDataTask.Initialize(EngineController, this))
                {
                    scheduler.ScheduleForExecution(setTraceDataTask);
                }
            }

            // If one or more custom node have been updated, make sure they
            // are compiled first before the home workspace gets evaluated.
            //
            EngineController.ProcessPendingCustomNodeSyncData(scheduler);

            var task = new UpdateGraphAsyncTask(scheduler, VerboseLogging);

            if (task.Initialize(EngineController, this))
            {
                task.Completed += OnUpdateGraphCompleted;
                RunEnabled      = false; // Disable 'Run' button.
                scheduler.ScheduleForExecution(task);
            }
            else
            {
                // Notify handlers that evaluation did not take place.
                var e = new EvaluationCompletedEventArgs(false);
                OnEvaluationCompleted(e);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method is typically called from the main application thread (as
        /// a result of user actions such as button click or node UI changes) to
        /// schedule an update of the graph. This call may or may not represent
        /// an actual update. In the event that the user action does not result
        /// in actual graph update (e.g. moving of node on UI), the update task
        /// will not be scheduled for execution.
        /// </summary>
        public void Run()
        {
            graphExecuted = true;

            // When Dynamo is shut down, the workspace is cleared, which results
            // in Modified() being called. But, we don't want to run when we are
            // shutting down so we check whether an engine controller is available.
            if (this.EngineController == null)
            {
                return;
            }

            var traceData = PreloadedTraceData;

            if ((traceData != null) && traceData.Any())
            {
                // If we do have preloaded trace data, set it here first.
                var setTraceDataTask = new SetTraceDataAsyncTask(scheduler);
                if (setTraceDataTask.Initialize(EngineController, this))
                {
                    scheduler.ScheduleForExecution(setTraceDataTask);
                }
            }

            // If one or more custom node have been updated, make sure they
            // are compiled first before the home workspace gets evaluated.
            //
            EngineController.ProcessPendingCustomNodeSyncData(scheduler);

            var task = new UpdateGraphAsyncTask(scheduler, verboseLogging);

            if (task.Initialize(EngineController, this))
            {
                task.Completed        += OnUpdateGraphCompleted;
                RunSettings.RunEnabled = false; // Disable 'Run' button.

                // Reset node states
                foreach (var node in Nodes)
                {
                    node.WasInvolvedInExecution = false;
                }

                // The workspace has been built for the first time
                silenceNodeModifications = false;

                OnEvaluationStarted(EventArgs.Empty);
                scheduler.ScheduleForExecution(task);

                // Setting this to true as the task is scheduled now and will be
                // set back to false once the OnUpdateGraphCompleted event is executed.
                executingTask = true;
            }
            else
            {
                // Notify handlers that evaluation did not take place.
                var e = new EvaluationCompletedEventArgs(false);
                OnEvaluationCompleted(e);
            }
        }