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


C# WorkflowApplication.RunEpisodeAsync方法代码示例

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


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

示例1: WhenActivityWithMultipleDelayIsRunAsyncCancelationTokenCanCancel

        public void WhenActivityWithMultipleDelayIsRunAsyncCancelationTokenCanCancel()
        {
            const string WaitForBookmarkName = "TestBookmark";

            // The WorkflowRuntime is not aware of the cancellation token and will not cancel the workflow
            // The WorkflowEpisode will cancel when the workflow becomes idle
            var workflowApplication =
                new WorkflowApplication(
                    new Sequence
                        {
                            Activities =
                                {
                                    new Delay { Duration = TimeSpan.FromMilliseconds(100) },
                                    new Delay { Duration = TimeSpan.FromMilliseconds(100) },
                                    new Delay { Duration = TimeSpan.FromMilliseconds(100) },
                                    new TestBookmark<int> { BookmarkName = WaitForBookmarkName }
                                }
                        });

            var tokenSource = new CancellationTokenSource();

            // Run the activity
            var task = workflowApplication.RunEpisodeAsync(WaitForBookmarkName, tokenSource.Token);

            // Immediately cancel
            tokenSource.Cancel();

            // Exception is thrown when Wait() or Result is accessed
            AssertHelper.Throws<TaskCanceledException>(task);
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:30,代码来源:WorkflowApplicationExtensionsTest.cs

示例2: WhenNoBookmarksAndOutArgRunAsyncShouldCompleteWithOutArgs

        public void WhenNoBookmarksAndOutArgRunAsyncShouldCompleteWithOutArgs()
        {
            const int Expected = 1;
            var workflowApplication = new WorkflowApplication(new EchoArg<int> { Value = Expected });

            var task = workflowApplication.RunEpisodeAsync(Constants.Timeout);

            Assert.IsNotNull(task);
            var result = task.Result;

            Assert.IsInstanceOfType(result, typeof(WorkflowCompletedEpisodeResult));

            var completedResult = (WorkflowCompletedEpisodeResult)result;
            Assert.IsNotNull(completedResult);
            Assert.AreEqual(ActivityInstanceState.Closed, completedResult.State);
            AssertOutArgument.AreEqual(completedResult.Outputs, "Result", Expected);
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:17,代码来源:WorkflowApplicationExtensionsTest.cs

示例3: WhenActivityWithBookmarkGoesIdleRunAsyncShouldReturnWorkflowIdleEpisodeResult

        public void WhenActivityWithBookmarkGoesIdleRunAsyncShouldReturnWorkflowIdleEpisodeResult()
        {
            var workflowApplication = new WorkflowApplication(new TestBookmark<int> { BookmarkName = "Test" });

            var result = workflowApplication.RunEpisodeAsync("Test", Constants.Timeout).Result;

            Assert.IsInstanceOfType(result, typeof(WorkflowIdleEpisodeResult));

            var idleEpisodeResult = (WorkflowIdleEpisodeResult)result;
            Assert.AreEqual(ActivityInstanceState.Executing, idleEpisodeResult.State);
            Assert.AreEqual(1, idleEpisodeResult.IdleArgs.Bookmarks.Count);
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:12,代码来源:WorkflowApplicationExtensionsTest.cs

示例4: WhenActivityWithBookmarkAndPersistenceGoesIdleRunAsyncShouldReturnWorkflowIdleEpisodeResult

        public void WhenActivityWithBookmarkAndPersistenceGoesIdleRunAsyncShouldReturnWorkflowIdleEpisodeResult()
        {
            var activity = new TestBookmark<int> { BookmarkName = "Test" };
            var workflowApplication = new WorkflowApplication(activity) { InstanceStore = new MemoryStore() };

            var result = workflowApplication.RunEpisodeAsync("Test", Constants.Timeout).Result;

            Assert.IsInstanceOfType(result, typeof(WorkflowIdleEpisodeResult));

            var completedResult = (WorkflowIdleEpisodeResult)result;
            Assert.AreEqual(ActivityInstanceState.Executing, completedResult.State);
            Assert.AreEqual(1, completedResult.IdleArgs.Bookmarks.Count);
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:13,代码来源:WorkflowApplicationExtensionsTest.cs

示例5: WhenActivityThrowsRunShouldThrowAggregateWithInnerSetToTerminatingException

        public void WhenActivityThrowsRunShouldThrowAggregateWithInnerSetToTerminatingException()
        {
            var workflowApplication =
                new WorkflowApplication(
                    new Throw { Exception = new InArgument<Exception>(ctx => new InvalidOperationException()) });

            AssertHelper.Throws<InvalidOperationException>(workflowApplication.RunEpisodeAsync(Constants.Timeout));
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:8,代码来源:WorkflowApplicationExtensionsTest.cs

示例6: WhenActivityThrowsAndUnhandledTerminateRequestedEpisodeShouldTerminate

        public void WhenActivityThrowsAndUnhandledTerminateRequestedEpisodeShouldTerminate()
        {
            var workflowApplication =
                new WorkflowApplication(
                    new Throw { Exception = new InArgument<Exception>(ctx => new InvalidOperationException()) });

            AssertHelper.Throws<InvalidOperationException>(
                workflowApplication.RunEpisodeAsync(UnhandledExceptionAction.Terminate));
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:9,代码来源:WorkflowApplicationExtensionsTest.cs

示例7: WhenActivityGoesIdleEpisodeContinuesUntilTrackingReportsActivityState

        public void WhenActivityGoesIdleEpisodeContinuesUntilTrackingReportsActivityState()
        {
            const string WaitForBookmarkName = "TestBookmark";

            var workflowApplication =
                new WorkflowApplication(
                    new Sequence
                        {
                            Activities =
                                {
                                    new Delay { Duration = TimeSpan.FromMilliseconds(1) },
                                    new Delay { Duration = TimeSpan.FromMilliseconds(1) },
                                    new Delay { Duration = TimeSpan.FromMilliseconds(1) },
                                    new TestBookmark<int> { BookmarkName = WaitForBookmarkName }
                                }
                        });

            // Run through three idle events and end the episode when idle with a bookmark "TestBookmark"
            var result = workflowApplication.RunEpisodeAsync(WaitForBookmarkName, Constants.Timeout).Result;

            Assert.IsInstanceOfType(result, typeof(WorkflowIdleEpisodeResult));
            Assert.AreEqual(ActivityInstanceState.Executing, result.State);
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:23,代码来源:WorkflowApplicationExtensionsTest.cs


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