WorkflowApplication.Abort 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이 워크플로 인스턴스가 중단되어야 함을 워크플로 런타임에 알립니다.
오버로드
| Abort() |
이 워크플로 인스턴스가 중단되어야 함을 워크플로 런타임에 알립니다. |
| Abort(String) |
지정한 원인에 대해 이 워크플로 인스턴스를 중단해야 함을 워크플로 런타임에 알립니다. |
설명
WorkflowApplication이 호스팅하는 워크플로가 중단되면 Aborted 처리기가 호출되고 Completed 처리기가 호출되지 않습니다.
Abort()
이 워크플로 인스턴스가 중단되어야 함을 워크플로 런타임에 알립니다.
public:
void Abort();
public void Abort ();
override this.Abort : unit -> unit
Public Sub Abort ()
예제
다음 예제에서는 .를 사용하여 WorkflowApplication워크플로를 호스트합니다. WorkflowApplication 인스턴스는 지정된 워크플로 정의를 사용하여 생성되고, 원하는 워크플로 수명 주기 이벤트가 처리되며, 워크플로는 호출을 통해 Run호출됩니다. 워크플로가 시작된 Abort 후 호출됩니다. 워크플로가 중단되면 다음 출력이 콘솔에 표시됩니다.
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();
설명
WorkflowApplication이 호스팅하는 워크플로가 중단되면 Aborted 처리기가 호출되고 Completed 처리기가 호출되지 않습니다.
적용 대상
Abort(String)
지정한 원인에 대해 이 워크플로 인스턴스를 중단해야 함을 워크플로 런타임에 알립니다.
public:
void Abort(System::String ^ reason);
public void Abort (string reason);
override this.Abort : string -> unit
Public Sub Abort (reason As String)
매개 변수
- reason
- String
요청 중단의 원인입니다.
예제
다음 예제에서는 .를 사용하여 WorkflowApplication워크플로를 호스트합니다. WorkflowApplication 인스턴스는 지정된 워크플로 정의를 사용하여 생성되고, 원하는 워크플로 수명 주기 이벤트가 처리되며, 워크플로는 호출을 통해 Run호출됩니다. 워크플로가 시작된 Abort 후 호출됩니다. 워크플로가 중단되면 다음 출력이 콘솔에 표시됩니다.
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();
설명
WorkflowApplication이 호스팅하는 워크플로가 중단되면 Aborted 처리기가 호출되고 Completed 처리기가 호출되지 않습니다.