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


C# WorkflowApplication.Terminate方法代码示例

本文整理汇总了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);
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:60,代码来源:Program.cs

示例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.");
        }
开发者ID:yinqunjun,项目名称:WF45GettingStartedTutorial,代码行数:26,代码来源:WorkflowHostForm.cs


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