本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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));
}
示例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);
}