WorkflowApplication.Abort Método

Definição

Notifica o runtime de fluxo de trabalho que esta instância do fluxo de trabalho deve ser anulada.Notifies the workflow runtime that this workflow instance should abort.

Sobrecargas

Abort()

Notifica o runtime de fluxo de trabalho que esta instância do fluxo de trabalho deve ser anulada.Notifies the workflow runtime that this workflow instance should abort.

Abort(String)

Notifica o runtime de fluxo de trabalho que esta instância do fluxo de trabalho deve ser anulada pelo motivo especificado.Notifies the workflow runtime that this workflow instance should abort for the specified reason.

Comentários

Quando um fluxo de trabalho hospedado por um WorkflowApplication é anulado, o Aborted manipulador é invocado e o Completed manipulador não é invocado.When a workflow hosted by a WorkflowApplication is aborted, the Aborted handler is invoked and the Completed handler is not invoked.

Abort()

Notifica o runtime de fluxo de trabalho que esta instância do fluxo de trabalho deve ser anulada.Notifies the workflow runtime that this workflow instance should abort.

public:
 void Abort();
public void Abort ();
override this.Abort : unit -> unit
Public Sub Abort ()

Exemplos

O exemplo a seguir hospeda um fluxo de trabalho usando WorkflowApplication.The following example hosts a workflow using WorkflowApplication. Uma WorkflowApplication instância é construída usando a definição de fluxo de trabalho especificada, os eventos de ciclo de vida de fluxo de trabalho desejados são tratados e o fluxo de trabalho é invocado com uma chamada para Run .A WorkflowApplication instance is constructed using the specified workflow definition, the desired workflow lifecycle events are handled, and the workflow is invoked with a call to Run. Depois que o fluxo de trabalho é iniciado, Abort é chamado.After the workflow is started, Abort is called. Quando o fluxo de trabalho é anulado, a saída a seguir é exibida para o console.When the workflow is aborted, the following output is displayed to the console.

Starting the workflow.   
Workflow 3b76d562-516a-4a52-b17c-0f2ce531ad93 Idle.   
Workflow 3b76d562-516a-4a52-b17c-0f2ce531ad93 Aborted  
Exception: System.Activities.WorkflowApplicationAbortedException  
The workflow has been aborted.  
Activity wf = new Sequence
{
    Activities =
     {
         new WriteLine
         {
             Text = "Starting the workflow."
         },
         new Delay
         {
             Duration = TimeSpan.FromSeconds(5)
         },
         new WriteLine
         {
             Text = "Ending the workflow."
         }
     }
};

// Create a WorkflowApplication instance.
WorkflowApplication wfApp = new WorkflowApplication(wf);

// Subscribe to any desired workflow lifecycle events.
wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
    if (e.CompletionState == ActivityInstanceState.Faulted)
    {
        Console.WriteLine("Workflow {0} Terminated.", e.InstanceId);
        Console.WriteLine("Exception: {0}\n{1}",
            e.TerminationException.GetType().FullName,
            e.TerminationException.Message);
    }
    else if (e.CompletionState == ActivityInstanceState.Canceled)
    {
        Console.WriteLine("Workflow {0} Canceled.", e.InstanceId);
    }
    else
    {
        Console.WriteLine("Workflow {0} Completed.", e.InstanceId);

        // Outputs can be retrieved from the Outputs dictionary,
        // keyed by argument name.
        // Console.WriteLine("The winner is {0}.", e.Outputs["Winner"]);
    }
};

wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
{
    // Display the exception that caused the workflow
    // to abort.
    Console.WriteLine("Workflow {0} Aborted.", e.InstanceId);
    Console.WriteLine("Exception: {0}\n{1}",
        e.Reason.GetType().FullName,
        e.Reason.Message);
};

wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
    // Perform any processing that should occur
    // when a workflow goes idle. If the workflow can persist,
    // both Idle and PersistableIdle are called in that order.
    Console.WriteLine("Workflow {0} Idle.", e.InstanceId);
};

wfApp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs e)
{
    // Instruct the runtime to persist and unload the workflow
    return PersistableIdleAction.Unload;
};

wfApp.Unloaded = delegate(WorkflowApplicationEventArgs e)
{
    Console.WriteLine("Workflow {0} Unloaded.", e.InstanceId);
};

wfApp.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
{
    // Display the unhandled exception.
    Console.WriteLine("OnUnhandledException in Workflow {0}\n{1}",
        e.InstanceId, e.UnhandledException.Message);

    Console.WriteLine("ExceptionSource: {0} - {1}",
        e.ExceptionSource.DisplayName, e.ExceptionSourceInstanceId);

    // Instruct the runtime to terminate the workflow.
    // Other choices are Abort and Cancel
    return UnhandledExceptionAction.Terminate;
};

// Run the workflow.
wfApp.Run();

Thread.Sleep(TimeSpan.FromSeconds(1));

wfApp.Abort();

Comentários

Quando um fluxo de trabalho hospedado por um WorkflowApplication é anulado, o Aborted manipulador é invocado e o Completed manipulador não é invocado.When a workflow hosted by a WorkflowApplication is aborted, the Aborted handler is invoked and the Completed handler is not invoked.

Aplica-se a

Abort(String)

Notifica o runtime de fluxo de trabalho que esta instância do fluxo de trabalho deve ser anulada pelo motivo especificado.Notifies the workflow runtime that this workflow instance should abort for the specified reason.

public:
 void Abort(System::String ^ reason);
public void Abort (string reason);
override this.Abort : string -> unit
Public Sub Abort (reason As String)

Parâmetros

reason
String

O motivo para a solicitação ser anulada.The reason for the request to abort.

Exemplos

O exemplo a seguir hospeda um fluxo de trabalho usando WorkflowApplication.The following example hosts a workflow using WorkflowApplication. Uma WorkflowApplication instância é construída usando a definição de fluxo de trabalho especificada, os eventos de ciclo de vida de fluxo de trabalho desejados são tratados e o fluxo de trabalho é invocado com uma chamada para Run .A WorkflowApplication instance is constructed using the specified workflow definition, the desired workflow lifecycle events are handled, and the workflow is invoked with a call to Run. Depois que o fluxo de trabalho é iniciado, Abort é chamado.After the workflow is started, Abort is called. Quando o fluxo de trabalho é anulado, a saída a seguir é exibida para o console.When the workflow is aborted, the following output is displayed to the console.

Starting the workflow.   
Workflow 607b042e-98db-4bbe-abe8-f4d750feec41 Idle.   
Workflow 607b042e-98db-4bbe-abe8-f4d750feec41 Aborted  
Exception: System.Activities.WorkflowApplicationAbortedException  
The reason for aborting the workflow.  
Activity wf = new Sequence
{
    Activities =
     {
         new WriteLine
         {
             Text = "Starting the workflow."
         },
         new Delay
         {
             Duration = TimeSpan.FromSeconds(5)
         },
         new WriteLine
         {
             Text = "Ending the workflow."
         }
     }
};

// Create a WorkflowApplication instance.
WorkflowApplication wfApp = new WorkflowApplication(wf);

// Subscribe to any desired workflow lifecycle events.
wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
    if (e.CompletionState == ActivityInstanceState.Faulted)
    {
        Console.WriteLine("Workflow {0} Terminated.", e.InstanceId);
        Console.WriteLine("Exception: {0}\n{1}",
            e.TerminationException.GetType().FullName,
            e.TerminationException.Message);
    }
    else if (e.CompletionState == ActivityInstanceState.Canceled)
    {
        Console.WriteLine("Workflow {0} Canceled.", e.InstanceId);
    }
    else
    {
        Console.WriteLine("Workflow {0} Completed.", e.InstanceId);

        // Outputs can be retrieved from the Outputs dictionary,
        // keyed by argument name.
        // Console.WriteLine("The winner is {0}.", e.Outputs["Winner"]);
    }
};

wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
{
    // Display the exception that caused the workflow
    // to abort.
    Console.WriteLine("Workflow {0} Aborted.", e.InstanceId);
    Console.WriteLine("Exception: {0}\n{1}",
        e.Reason.GetType().FullName,
        e.Reason.Message);
};

wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
    // Perform any processing that should occur
    // when a workflow goes idle. If the workflow can persist,
    // both Idle and PersistableIdle are called in that order.
    Console.WriteLine("Workflow {0} Idle.", e.InstanceId);
};

wfApp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs e)
{
    // Instruct the runtime to persist and unload the workflow
    return PersistableIdleAction.Unload;
};

wfApp.Unloaded = delegate(WorkflowApplicationEventArgs e)
{
    Console.WriteLine("Workflow {0} Unloaded.", e.InstanceId);
};

wfApp.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
{
    // Display the unhandled exception.
    Console.WriteLine("OnUnhandledException in Workflow {0}\n{1}",
        e.InstanceId, e.UnhandledException.Message);

    Console.WriteLine("ExceptionSource: {0} - {1}",
        e.ExceptionSource.DisplayName, e.ExceptionSourceInstanceId);

    // Instruct the runtime to terminate the workflow.
    // Other choices are Abort and Cancel
    return UnhandledExceptionAction.Terminate;
};

// Run the workflow.
wfApp.Run();

Thread.Sleep(TimeSpan.FromSeconds(1));

wfApp.Abort();

Comentários

Quando um fluxo de trabalho hospedado por um WorkflowApplication é anulado, o Aborted manipulador é invocado e o Completed manipulador não é invocado.When a workflow hosted by a WorkflowApplication is aborted, the Aborted handler is invoked and the Completed handler is not invoked.

Aplica-se a