WorkflowInvoker.EndInvoke(IAsyncResult) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Devolve os resultados de um fluxo de trabalho que foi invocado usando uma das BeginInvoke sobrecargas.
public:
System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ EndInvoke(IAsyncResult ^ result);
public System.Collections.Generic.IDictionary<string,object> EndInvoke(IAsyncResult result);
member this.EndInvoke : IAsyncResult -> System.Collections.Generic.IDictionary<string, obj>
Public Function EndInvoke (result As IAsyncResult) As IDictionary(Of String, Object)
Parâmetros
- result
- IAsyncResult
O IAsyncResult que faz referência à BeginInvoke operação que iniciou o fluxo de trabalho.
Devoluções
Um dicionário das atividades OutArgument raiz e InOutArgument dos valores indexados pelo nome do argumento que representam as saídas do fluxo de trabalho.
Exemplos
O exemplo seguinte invoca um fluxo de trabalho composto por uma LongRunningDiceRoll atividade. A atividade LongRunningDiceRoll tem dois argumentos de saída que representam os resultados da operação de rolagem de dados. Estes são recuperados chamando EndInvoke. Quando a chamada retorna EndInvoke , cada argumento de saída é devolvido no dicionário de saídas, indexado pelo nome do argumento.
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))
}
}
};
}
}
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.");
}
Observações
Para ser notificado quando o fluxo de trabalho estiver completo e recuperar os parâmetros de saída do fluxo, chame EndInvoke do callback método especificado por BeginInvoke. Se EndInvoke for chamado antes do fluxo de trabalho terminar, bloqueia-se até que o fluxo de trabalho termine.
Este método devolve o resultado de um fluxo de trabalho invocado de forma assíncrona usando o IAsyncResult padrão de design assíncrono. Para mais informações, consulte Visão Geral de Programação Assíncrona.