WorkflowInvoker.InvokeCompleted 이벤트

정의

InvokeAsync 오버로드 중 하나에 의해 호출된 워크플로가 완료되거나 취소될 때 발생합니다.

public:
 event EventHandler<System::Activities::InvokeCompletedEventArgs ^> ^ InvokeCompleted;
public event EventHandler<System.Activities.InvokeCompletedEventArgs> InvokeCompleted;
member this.InvokeCompleted : EventHandler<System.Activities.InvokeCompletedEventArgs> 
Public Custom Event InvokeCompleted As EventHandler(Of InvokeCompletedEventArgs) 
Public Event InvokeCompleted As EventHandler(Of InvokeCompletedEventArgs) 

이벤트 유형

예제

다음 예제에서는 하나의 LongRunningDiceRoll 활동으로 구성된 워크플로를 호출합니다. LongRunningDiceRoll 활동에는 주사위 굴리기 작업의 결과를 나타내는 두 개의 출력 인수가 있습니다. 워크플로가 완료되면 InvokeCompleted 처리기에서 이러한 인수가 검색됩니다.

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))
                }
            }
        };
    }
}
AutoResetEvent syncEvent = new AutoResetEvent(false);

WorkflowInvoker invoker = new WorkflowInvoker(new LongRunningDiceRoll());

invoker.InvokeCompleted += delegate(object sender, InvokeCompletedEventArgs args)
{
    if (args.Cancelled == true)
    {
        Console.WriteLine("Workflow was cancelled.");
    }
    else if (args.Error != null)
    {
        Console.WriteLine("Exception: {0}\n{1}",
            args.Error.GetType().FullName,
            args.Error.Message);
    }
    else
    {
        Console.WriteLine("The two dice are {0} and {1}.",
            args.Outputs["D1"], args.Outputs["D2"]);
    }

    syncEvent.Set();
};

invoker.InvokeAsync("InvokeAsync Example");

Console.WriteLine("Waiting for the workflow to complete.");

// Wait for the workflow to complete.
syncEvent.WaitOne();

Console.WriteLine("The workflow is complete.");

설명

이를 처리하면 InvokeAsync 오버로드 중 하나를 사용하여 호출된 워크플로가 완료되었는지 확인하고 완료된 워크플로의 출력 인수를 검색할 수 있습니다.

적용 대상