當前位置: 首頁>>代碼示例>>C#>>正文


C# WorkflowInvoker.BeginInvoke方法代碼示例

本文整理匯總了C#中System.Activities.WorkflowInvoker.BeginInvoke方法的典型用法代碼示例。如果您正苦於以下問題:C# WorkflowInvoker.BeginInvoke方法的具體用法?C# WorkflowInvoker.BeginInvoke怎麽用?C# WorkflowInvoker.BeginInvoke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Activities.WorkflowInvoker的用法示例。


在下文中一共展示了WorkflowInvoker.BeginInvoke方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: LongRunningDiceRoll

public sealed class LongRunningDiceRoll : Activity
{
    public OutArgument<int> D1 { get; set; }
    public OutArgument<int> D2 { get; set; }

    public LongRunningDiceRoll()
    {
        this.Implementation = () => new Sequence
        {
            Activities =
            {
                new WriteLine
                {
                    Text = "Rolling the dice for 5 seconds."
                },
                new Delay
                {
                    Duration = TimeSpan.FromSeconds(5)
                },
                new DiceRoll
                {
                    D1 = new OutArgument<int>(env => this.D1.Get(env)),
                    D2 = new OutArgument<int>(env => this.D2.Get(env))
                }
            }
        };
    }
}
開發者ID:.NET開發者,項目名稱:System.Activities,代碼行數:28,代碼來源:WorkflowInvoker.BeginInvoke

示例2: BeginInvokeExample

static void BeginInvokeExample()
{
    WorkflowInvoker invoker = new WorkflowInvoker(new LongRunningDiceRoll());

    string userState = "BeginInvoke example";
    IAsyncResult result = invoker.BeginInvoke(new AsyncCallback(WorkflowCompletedCallback), userState);

    // You can inspect result from the host to determine if the workflow
    // is complete.
    Console.WriteLine("result.IsCompleted: {0}", result.IsCompleted);

    // The results of the workflow are retrieved by calling EndInvoke, which
    // can be called from the callback or from the host. If called from the
    // host, it blocks until the workflow completes. If a callback is not
    // required, pass null for the callback parameter.
    Console.WriteLine("Waiting for the workflow to complete.");
    IDictionary<string, object> outputs = invoker.EndInvoke(result);

    Console.WriteLine("The two dice are {0} and {1}.",
        outputs["D1"], outputs["D2"]);
}

static void WorkflowCompletedCallback(IAsyncResult result)
{
    Console.WriteLine("Workflow complete.");
}
開發者ID:.NET開發者,項目名稱:System.Activities,代碼行數:26,代碼來源:WorkflowInvoker.BeginInvoke


注:本文中的System.Activities.WorkflowInvoker.BeginInvoke方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。