Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs when the workflow invoked by one of the InvokeAsync overloads is completed or canceled.
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)
The following example invokes a workflow consisting of a LongRunningDiceRoll
activity. The LongRunningDiceRoll
activity has two output arguments that represent the results of the dice roll operation. When the workflow completes these are retrieved in the InvokeCompleted handler.
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)
{
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.");
Handle this to determine whether a workflow invoked with one of the InvokeAsync overloads completed successfully and to retrieve the output arguments of the completed workflow.
Product | Versions |
---|---|
.NET Framework | 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in