当前位置: 首页>>代码示例>>C#>>正文


C# DynamoScheduler.ScheduleForExecution方法代码示例

本文整理汇总了C#中Dynamo.Core.Threading.DynamoScheduler.ScheduleForExecution方法的典型用法代码示例。如果您正苦于以下问题:C# DynamoScheduler.ScheduleForExecution方法的具体用法?C# DynamoScheduler.ScheduleForExecution怎么用?C# DynamoScheduler.ScheduleForExecution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dynamo.Core.Threading.DynamoScheduler的用法示例。


在下文中一共展示了DynamoScheduler.ScheduleForExecution方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestTaskStateChangedEventHandling

        public void TestTaskStateChangedEventHandling()
        {
            var observer = new TaskEventObserver();
            var schedulerThread = new SampleSchedulerThread();
            var scheduler = new DynamoScheduler(schedulerThread, false);
            scheduler.TaskStateChanged += observer.OnTaskStateChanged;

            // Start scheduling a bunch of tasks.
            var asyncTasks = new AsyncTask[]
            {
                new ErrorProneAsyncTask(scheduler, 7), 
                new InconsequentialAsyncTask(scheduler, 100),
                new PrioritizedAsyncTask(scheduler, 1),
                new PrioritizedAsyncTask(scheduler, 5),
                new ErrorProneAsyncTask(scheduler, 3), 
                new InconsequentialAsyncTask(scheduler, 500),
                new InconsequentialAsyncTask(scheduler, 300),
                new PrioritizedAsyncTask(scheduler, 3), 
                new ErrorProneAsyncTask(scheduler, 5), 
            };

            foreach (SampleAsyncTask asyncTask in asyncTasks)
                scheduler.ScheduleForExecution(asyncTask);

            schedulerThread.GetSchedulerToProcessTasks();

            // Drops all InconsequentialAsyncTask and leave behind one.
            // Kept all PrioritizedAsyncTask instances and sorted them.
            var expected = new List<string>
            {
                // Scheduling notifications...

                "Scheduled: ErrorProneAsyncTask: 7",
                "Scheduled: InconsequentialAsyncTask: 100",
                "Scheduled: PrioritizedAsyncTask: 1",
                "Scheduled: PrioritizedAsyncTask: 5",
                "Scheduled: ErrorProneAsyncTask: 3",
                "Scheduled: InconsequentialAsyncTask: 500",
                "Scheduled: InconsequentialAsyncTask: 300",
                "Scheduled: PrioritizedAsyncTask: 3",
                "Scheduled: ErrorProneAsyncTask: 5",

                // Task discarded notifications...

                "Discarded: InconsequentialAsyncTask: 100",
                "Discarded: InconsequentialAsyncTask: 300",

                // Execution of remaining tasks...

                "ExecutionStarting: ErrorProneAsyncTask: 7",
                "ExecutionFailed: ErrorProneAsyncTask: 7",
                "CompletionHandled: ErrorProneAsyncTask: 7",

                "ExecutionStarting: PrioritizedAsyncTask: 1",
                "ExecutionCompleted: PrioritizedAsyncTask: 1",
                "CompletionHandled: PrioritizedAsyncTask: 1",

                "ExecutionStarting: PrioritizedAsyncTask: 5",
                "ExecutionCompleted: PrioritizedAsyncTask: 5",
                "CompletionHandled: PrioritizedAsyncTask: 5",

                "ExecutionStarting: ErrorProneAsyncTask: 3",
                "ExecutionFailed: ErrorProneAsyncTask: 3",
                "CompletionHandled: ErrorProneAsyncTask: 3",

                "ExecutionStarting: PrioritizedAsyncTask: 3",
                "ExecutionCompleted: PrioritizedAsyncTask: 3",
                "CompletionHandled: PrioritizedAsyncTask: 3",

                "ExecutionStarting: ErrorProneAsyncTask: 5",
                "ExecutionFailed: ErrorProneAsyncTask: 5",
                "CompletionHandled: ErrorProneAsyncTask: 5",

                // Execution of InconsequentialAsyncTask last...

                "ExecutionStarting: InconsequentialAsyncTask: 500",
                "ExecutionCompleted: InconsequentialAsyncTask: 500",
                "CompletionHandled: InconsequentialAsyncTask: 500"
            };

            Assert.AreEqual(expected.Count, observer.Results.Count());

            int index = 0;
            foreach (var actual in observer.Results)
            {
                Assert.AreEqual(expected[index++], actual);
            }
        }
开发者ID:qingemeng,项目名称:Dynamo,代码行数:88,代码来源:SchedulerTests.cs

示例2: ProcessPendingCustomNodeSyncData

        /// <summary>
        /// DynamoModel calls this method prior to scheduling a graph update for
        /// the home workspace. This method is called to schedule custom node 
        /// compilation since the home workspace update may depend on it. Any 
        /// updates to a CustomNodeDefinition will cause GraphSyncData to be added 
        /// to "pendingCustomNodeSyncData" queue.
        /// </summary>
        /// <param name="scheduler">The scheduler on which custom node compilation 
        /// task can be scheduled.</param>
        /// 
        internal void ProcessPendingCustomNodeSyncData(DynamoScheduler scheduler)
        {
            while (pendingCustomNodeSyncData.Count > 0)
            {
                var initParams = new CompileCustomNodeParams()
                {
                    SyncData = pendingCustomNodeSyncData.Dequeue(),
                    EngineController = this
                };

                var compileTask = new CompileCustomNodeAsyncTask(scheduler);
                if (compileTask.Initialize(initParams))
                    scheduler.ScheduleForExecution(compileTask);
            }
        }
开发者ID:whztt07,项目名称:Dynamo,代码行数:25,代码来源:EngineController.cs

示例3: TestTaskQueuePreProcessing05

        public void TestTaskQueuePreProcessing05()
        {
            var schedulerThread = new SampleSchedulerThread();
            var scheduler = new DynamoScheduler(schedulerThread, false);

            // Start scheduling a bunch of tasks.
            var asyncTasks = new AsyncTask[]
            {
                new PrioritizedAsyncTask(scheduler, 1), 
                new InconsequentialAsyncTask(scheduler, 100),
            };

            var results = new List<string>();
            foreach (SampleAsyncTask asyncTask in asyncTasks)
            {
                asyncTask.InitializeWithResultList(results);
                scheduler.ScheduleForExecution(asyncTask);
            }

            schedulerThread.GetSchedulerToProcessTasks();

            // Drops all InconsequentialAsyncTask and leave behind one.
            // Kept all PrioritizedAsyncTask instances and sorted them.
            Assert.AreEqual(2, results.Count);
            Assert.AreEqual("PrioritizedAsyncTask: 1", results[0]);
            Assert.AreEqual("InconsequentialAsyncTask: 100", results[1]);
        }
开发者ID:qingemeng,项目名称:Dynamo,代码行数:27,代码来源:SchedulerTests.cs


注:本文中的Dynamo.Core.Threading.DynamoScheduler.ScheduleForExecution方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。