WorkflowInvoker.InvokeCompleted Kejadian
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Terjadi ketika alur kerja yang dipanggil oleh salah InvokeAsync satu kelebihan beban selesai atau dibatalkan.
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)
Jenis Acara
Contoh
Contoh berikut memanggil alur kerja yang terdiri dari LongRunningDiceRoll
aktivitas. Aktivitas LongRunningDiceRoll
memiliki dua argumen output yang mewakili hasil operasi pelemparan dadu. Ketika alur kerja selesai, ini diambil di 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 == 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.");
Keterangan
Tangani ini untuk menentukan apakah alur kerja yang dipanggil dengan salah InvokeAsync satu kelebihan beban berhasil diselesaikan dan untuk mengambil argumen output dari alur kerja yang telah selesai.