本文整理汇总了C#中System.Activities.WorkflowApplication.Terminate方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowApplication.Terminate方法的具体用法?C# WorkflowApplication.Terminate怎么用?C# WorkflowApplication.Terminate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Activities.WorkflowApplication
的用法示例。
在下文中一共展示了WorkflowApplication.Terminate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args)
{
const int workflowCompleted = 0;
const int workflowIdle = 1;
var syncEvents = new[]
{
new AutoResetEvent(false),
new AutoResetEvent(false),
};
var wfApp = new WorkflowApplication(new TestReadLine());
string bookmarkName = string.Empty;
bool workflowComplete = false;
// Signal the main thread we are done
wfApp.Completed = (e) => syncEvents[workflowCompleted].Set();
// When the host detects an idle
wfApp.Idle = (e) =>
{
// Search the bookmarks
foreach (
var bi in
e.Bookmarks.Where(
bi => bi.BookmarkName == "FirstName" || bi.BookmarkName == "LastName"))
{
Console.WriteLine("Found bookmark {0}", bi.BookmarkName);
// For FirstName or LastName bookmarks prompt with a readline
bookmarkName = bi.BookmarkName;
syncEvents[workflowIdle].Set();
}
};
wfApp.Run();
while (!workflowComplete)
{
// Wait for events
switch (WaitHandle.WaitAny(syncEvents, TimeSpan.FromSeconds(5)))
{
case WaitHandle.WaitTimeout:
Console.WriteLine("Sorry you took too long");
wfApp.Terminate("Timeout");
break;
case workflowCompleted:
workflowComplete = true;
break;
case workflowIdle:
Console.WriteLine("Reading response for bookmark {0}", bookmarkName);
// Resume with the response from the user
wfApp.ResumeBookmark(bookmarkName, Console.ReadLine());
break;
}
}
Console.WriteLine("Sample Completed - press any key to exit");
Console.ReadKey(true);
}
示例2: QuitGame_Click
private void QuitGame_Click(object sender, EventArgs e)
{
if (WorkflowInstanceId == Guid.Empty)
{
MessageBox.Show("Please select a workflow.");
return;
}
WorkflowApplicationInstance instance = WorkflowApplication.GetInstance(WorkflowInstanceId, store);
// Use the persisted WorkflowIdentity to retrieve the correct workflow
// definition from the dictionary.
Activity wf = WorkflowVersionMap.GetWorkflowDefinition(instance.DefinitionIdentity);
// Associate the WorkflowApplication with the correct definition
WorkflowApplication wfApp = new WorkflowApplication(wf, instance.DefinitionIdentity);
// Configure the extensions and lifecycle handlers
ConfigureWorkflowApplication(wfApp);
// Load the workflow.
wfApp.Load(instance);
// Terminate the workflow.
wfApp.Terminate("User resigns.");
}