You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/develop/dotnet/cancellation.mdx
+86-16Lines changed: 86 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,9 @@
2
2
id: cancellation
3
3
title: Interrupt a Workflow - .NET SDK
4
4
sidebar_label: Interrupt a Workflow
5
-
description: Interrupt Workflow Execution in .NET using the Temporal SDK. Cancel for graceful stops; terminate for forceful stops. Handle Cancellation in Workflow and Activities efficiently.
5
+
description:
6
+
Interrupt Workflow Execution in .NET using the Temporal SDK. Cancel for graceful stops; terminate for forceful stops.
7
+
Handle Cancellation in Workflow and Activities efficiently.
6
8
toc_max_heading_level: 4
7
9
keywords:
8
10
- interrupt workflow execution
@@ -39,16 +41,15 @@ You can interrupt a Workflow Execution in one of the following ways:
39
41
-[Cancel](#cancellation): Canceling a Workflow provides a graceful way to stop Workflow Execution.
40
42
-[Terminate](#termination): Terminating a Workflow forcefully stops Workflow Execution.
41
43
42
-
Terminating a Workflow forcefully stops Workflow Execution.
43
-
This action resembles killing a process.
44
+
Terminating a Workflow forcefully stops Workflow Execution. This action resembles killing a process.
44
45
45
46
- The system records a `WorkflowExecutionTerminated` event in the Workflow History.
46
47
- The termination forcefully and immediately stops the Workflow Execution.
47
48
- The Workflow code gets no chance to handle termination.
48
49
- A Workflow Task doesn't get scheduled.
49
50
50
-
In most cases, canceling is preferable because it allows the Workflow to finish gracefully.
51
-
Terminate only if the Workflow is stuck and cannot be canceled normally.
51
+
In most cases, canceling is preferable because it allows the Workflow to finish gracefully. Terminate only if the
52
+
Workflow is stuck and cannot be canceled normally.
52
53
53
54
## Cancellation {#cancellation}
54
55
@@ -63,11 +64,12 @@ To give a Workflow and its Activities the ability to be cancelled, do the follow
63
64
64
65
**How to handle a Cancellation in a Workflow in .NET.**
65
66
66
-
Workflow Definitions can be written to respond to cancellation requests.
67
-
It is common for an Activity to be run on Cancellation to perform cleanup.
67
+
Workflow Definitions can be written to respond to cancellation requests. It is common for an Activity to be run on
68
+
Cancellation to perform cleanup.
68
69
69
-
Cancellation Requests on Workflows cancel the `Workflow.CancellationToken`.
70
-
This is the token that is implicitly used for all calls within the workflow as well (e.g. Timers, Activities, etc) and therefore cancellation is propagated to them to be handled and bubble out.
70
+
Cancellation Requests on Workflows cancel the `Workflow.CancellationToken`. This is the token that is implicitly used
71
+
for all calls within the workflow as well (e.g. Timers, Activities, etc) and therefore cancellation is propagated to
72
+
them to be handled and bubble out.
71
73
72
74
```csharp
73
75
[WorkflowRun]
@@ -111,9 +113,10 @@ public async Task RunAsync()
111
113
112
114
**How to handle a Cancellation in an Activity using the Temporal .NET SDK**
113
115
114
-
Ensure that the Activity is [Heartbeating](/develop/dotnet/failure-detection#activity-heartbeats) to receive the Cancellation request and stop execution.
115
-
Also make sure that the [Heartbeat Timeout](/develop/dotnet/failure-detection#heartbeat-timeout) is set on the Activity Options when calling from the Workflow.
116
-
An Activity Cancellation Request cancels the `CancellationToken` on the `ActivityExecutionContext`.
116
+
Ensure that the Activity is [Heartbeating](/develop/dotnet/failure-detection#activity-heartbeats) to receive the
117
+
Cancellation request and stop execution. Also make sure that the
118
+
[Heartbeat Timeout](/develop/dotnet/failure-detection#heartbeat-timeout) is set on the Activity Options when calling
119
+
from the Workflow. An Activity Cancellation Request cancels the `CancellationToken` on the `ActivityExecutionContext`.
117
120
118
121
```csharp
119
122
[Activity]
@@ -150,8 +153,8 @@ await handle.CancelAsync();
150
153
151
154
**How to request Cancellation of an Activity in .NET using the Temporal .NET SDK**
152
155
153
-
By default, Activities are automatically cancelled when the Workflow is cancelled since the workflow cancellation token is used by activities by default.
154
-
To issue a cancellation explicitly, a new cancellation token can be created.
156
+
By default, Activities are automatically cancelled when the Workflow is cancelled since the workflow cancellation token
157
+
is used by activities by default. To issue a cancellation explicitly, a new cancellation token can be created.
155
158
156
159
```csharp
157
160
[WorkflowRun]
@@ -187,7 +190,9 @@ public async Task RunAsync()
187
190
188
191
**How to Terminate a Workflow Execution in .NET using the Temporal .NET SDK**
189
192
190
-
To Terminate a Workflow Execution in .NET, use the [TerminateAsync()](https://dotnet.temporal.io/api/Temporalio.Client.WorkflowHandle.html#Temporalio_Client_WorkflowHandle_TerminateAsync_System_String_Temporalio_Client_WorkflowTerminateOptions_) method on the Workflow handle.
193
+
To Terminate a Workflow Execution in .NET, use the
Copy file name to clipboardExpand all lines: docs/develop/go/cancellation.mdx
+84-14Lines changed: 84 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,9 @@
2
2
id: cancellation
3
3
title: Interrupt a Workflow - Go SDK
4
4
sidebar_label: Interrupt a Workflow Execution
5
-
description: Handle Cancellations in Temporal Workflows and Activities, set Activity Heartbeat Timeouts, and send Cancellation requests from a Temporal Client in Go.
5
+
description:
6
+
Handle Cancellations in Temporal Workflows and Activities, set Activity Heartbeat Timeouts, and send Cancellation
7
+
requests from a Temporal Client in Go.
6
8
toc_max_heading_level: 4
7
9
keywords:
8
10
- cancellation
@@ -26,14 +28,19 @@ This pages shows the following:
26
28
27
29
**How to handle a Cancellation in a Workflow in Go.**
28
30
29
-
Workflow Definitions can be written to handle execution cancellation requests with Go's `defer` and the `workflow.NewDisconnectedContext` API.
30
-
In the Workflow Definition, there is a special Activity that handles clean up should the execution be cancelled.
31
+
Workflow Definitions can be written to handle execution cancellation requests with Go's `defer` and the
32
+
`workflow.NewDisconnectedContext` API. In the Workflow Definition, there is a special Activity that handles clean up
33
+
should the execution be cancelled.
31
34
32
-
If the Workflow receives a Cancellation Request, but all Activities gracefully handle the Cancellation, and/or no Activities are skipped then the Workflow status will be Complete.
33
-
It is completely up to the needs of the business process and your use case which determines whether you want to return the Cancellation error to show a Canceled status or Complete status regardless of whether a Cancellation has propagated to and/or skipped Activities.
35
+
If the Workflow receives a Cancellation Request, but all Activities gracefully handle the Cancellation, and/or no
36
+
Activities are skipped then the Workflow status will be Complete. It is completely up to the needs of the business
37
+
process and your use case which determines whether you want to return the Cancellation error to show a Canceled status
38
+
or Complete status regardless of whether a Cancellation has propagated to and/or skipped Activities.
Copy file name to clipboardExpand all lines: docs/develop/go/index.mdx
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,6 +87,7 @@ Send messages to and read the state of Workflow Executions.
87
87
Interrupt a Workflow Execution with a Cancel or Terminate action.
88
88
89
89
-[Handle a Workflow Cancellation Request](/develop/go/cancellation#handle-cancellation-in-workflow): Interrupt a Workflow Execution and its Activities through Workflow cancellation.
90
+
-[Reset a Workflow](/develop/go/cancellation#reset): Resume a Workflow Execution from an earlier point in its Event History.
0 commit comments