-
Notifications
You must be signed in to change notification settings - Fork 306
refactor(dotnet): updated /develop/dotnet to restructure content #4260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
flippedcoder
merged 4 commits into
mm/restructure-sdk-content
from
mm/dotnet-core-apps-decouple
Apr 3, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| --- | ||
| id: basics | ||
| title: Activity basics - .NET SDK | ||
| sidebar_label: Activity basics | ||
| description: This section explains Activity basics with the .NET SDK | ||
| toc_max_heading_level: 4 | ||
| keywords: | ||
| - .NET SDK | ||
| tags: | ||
| - .NET SDK | ||
| - Temporal SDKs | ||
| --- | ||
|
|
||
| ## Develop an Activity {#develop-activity} | ||
|
|
||
| One of the primary things that Workflows do is orchestrate the execution of Activities. | ||
| An Activity is a normal method execution that's intended to execute a single, well-defined action (either short or long-running), such as querying a database, calling a third-party API, or transcoding a media file. | ||
| An Activity can interact with world outside the Temporal Platform or use a Temporal Client to interact with a Temporal Service. | ||
| For the Workflow to be able to execute the Activity, we must define the [Activity Definition](/activity-definition). | ||
|
|
||
| You can develop an Activity Definition by using the `[Activity]` attribute from the `Temporalio.Activities` namespace on the method. | ||
| To register a method as an Activity with a custom name, use an attribute parameter, for example `[Activity("your-activity")]`. | ||
| Otherwise, the activity name is the unqualified method name (sans an "Async" suffix if the method is async). | ||
|
|
||
| Activities can be asynchronous or synchronous. | ||
|
|
||
| ```csharp | ||
| using Temporalio.Activities; | ||
|
|
||
| public class MyActivities | ||
| { | ||
| // Activities can be async and/or static too. We just demonstrate instance methods since many | ||
| // use them that way. | ||
| [Activity] | ||
| public string MyActivity(MyActivityParams input) => | ||
| $"{input.Greeting}, {input.Name}!"; | ||
| } | ||
| ``` | ||
|
|
||
| There is no explicit limit to the total number of parameters that an [Activity Definition](/activity-definition) may support. | ||
| However, there is a limit to the total size of the data that ends up encoded into a gRPC message Payload. | ||
|
|
||
| A single argument is limited to a maximum size of 2 MB. | ||
| And the total size of a gRPC message, which includes all the arguments, is limited to a maximum of 4 MB. | ||
|
|
||
| Also, keep in mind that all Payload data is recorded in the [Workflow Execution Event History](/workflow-execution/event#event-history) and large Event Histories can affect Worker performance. | ||
| This is because the entire Event History could be transferred to a Worker Process with a [Workflow Task](/tasks#workflow-task). | ||
|
|
||
| Some SDKs require that you pass context objects, others do not. | ||
| When it comes to your application data—that is, data that is serialized and encoded into a Payload—we recommend that you use a single object as an argument that wraps the application data passed to Activities. | ||
| This is so that you can change what data is passed to the Activity without breaking a method signature. | ||
|
|
||
| Activity parameters are the method parameters of the method with the `[Activity]` attribute. | ||
| These can be any data type Temporal can convert, including records. | ||
| Technically this can be multiple parameters, but Temporal strongly encourages a single parameter containing all input fields. |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| --- | ||
| id: dynamic-activity | ||
| title: Dynamic Activity - .NET SDK | ||
| sidebar_label: Dynamic Activity | ||
| description: This section explains Dynamic Activities with the .NET SDK | ||
| toc_max_heading_level: 4 | ||
| keywords: | ||
| - .NET SDK | ||
| tags: | ||
| - .NET SDK | ||
| - Temporal SDKs | ||
| --- | ||
|
|
||
| ## Set a Dynamic Activity {#set-a-dynamic-activity} | ||
|
|
||
| **How to set a Dynamic Activity using the Temporal .NET SDK** | ||
|
|
||
| A Dynamic Activity in Temporal is an Activity that is invoked dynamically at runtime if no other Activity with the same name is registered. | ||
| An Activity can be made dynamic by setting `Dynamic` as `true` on the `[Activity]` attribute. | ||
| You must register the Activity with the Worker before it can be invoked. | ||
| Only one Dynamic Activity can be present on a Worker. | ||
|
|
||
| The Activity Definition must then accept a single argument of type `Temporalio.Converters.IRawValue[]`. | ||
| The [PayloadConverter](https://dotnet.temporal.io/api/Temporalio.Activities.ActivityExecutionContext.html#Temporalio_Activities_ActivityExecutionContext_PayloadConverter) property on the `ActivityExecutionContext` is used to convert an `IRawValue` object to the desired type using extension methods in the `Temporalio.Converters` namespace. | ||
|
|
||
| ```csharp | ||
| public class MyActivities | ||
| { | ||
| [Activity(Dynamic = true)] | ||
| public string DynamicActivity(IRawValue[] args) | ||
| { | ||
| var input = ActivityExecutionContext.Current.PayloadConverter.ToValue<MyActivityParams>(args.Single()); | ||
| return $"{input.Greeting}, {input.Name}!"; | ||
| } | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| id: execution | ||
| title: Activity execution - .NET SDK | ||
| description: Shows how to perform Activity execution with the .NET SDK | ||
| sidebar_label: Activity execution | ||
| slug: /develop/dotnet/activities/execution | ||
| toc_max_heading_level: 3 | ||
| tags: | ||
| - .NET SDK | ||
| - Temporal SDKs | ||
| - Activity | ||
| --- | ||
|
|
||
| ## Start Activity Execution {#activity-execution} | ||
|
|
||
| Calls to spawn [Activity Executions](/activity-execution) are written within a [Workflow Definition](/workflow-definition). | ||
| The call to spawn an Activity Execution generates the [ScheduleActivityTask](/references/commands#scheduleactivitytask) Command. | ||
| This results in the set of three [Activity Task](/tasks#activity-task) related Events ([ActivityTaskScheduled](/references/events#activitytaskscheduled), [ActivityTaskStarted](/references/events#activitytaskstarted), and ActivityTask[Closed]) in your Workflow Execution Event History. | ||
|
|
||
| A single instance of the Activities implementation is shared across multiple simultaneous Activity invocations. | ||
| Activity implementation code should be _idempotent_. | ||
|
|
||
| The values passed to Activities through invocation parameters or returned through a result value are recorded in the Execution history. | ||
| The entire Execution history is transferred from the Temporal service to Workflow Workers when a Workflow state needs to recover. | ||
| A large Execution history can thus adversely impact the performance of your Workflow. | ||
|
|
||
| Therefore, be mindful of the amount of data you transfer through Activity invocation parameters or Return Values. | ||
| Otherwise, no additional limitations exist on Activity implementations. | ||
|
|
||
| To spawn an Activity Execution, use the `ExecuteActivityAsync` operation from within your Workflow Definition. | ||
|
|
||
| ```csharp | ||
| using Temporalio.Workflows; | ||
|
|
||
| [Workflow] | ||
| public class MyWorkflow | ||
| { | ||
| public async Task<string> RunAsync(string name) | ||
| { | ||
| var param = MyActivityParams("Hello", name); | ||
| return await Workflow.ExecuteActivityAsync( | ||
| (MyActivities a) => a.MyActivity(param), | ||
| new() { StartToCloseTimeout = TimeSpan.FromMinutes(5) }); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Activity Execution semantics rely on several parameters. | ||
| The only required value that needs to be set is either a [Schedule-To-Close Timeout](/encyclopedia/detecting-activity-failures#schedule-to-close-timeout) or a [Start-To-Close Timeout](/encyclopedia/detecting-activity-failures#start-to-close-timeout). | ||
| These values are set in the Activity Options. | ||
|
|
||
| ### Get Activity Execution results {#get-activity-results} | ||
|
|
||
| The Activity result is returned in the Task from the `ExecuteActivityAsync` call. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| id: index | ||
| title: Activities - .NET SDK | ||
| sidebar_label: Activities | ||
| description: This section explains how to implement Activities with the .NET SDK | ||
| toc_max_heading_level: 4 | ||
| keywords: | ||
| - .NET SDK | ||
| tags: | ||
| - .NET SDK | ||
| - Temporal SDKs | ||
| --- | ||
|
|
||
| import * as Components from '@site/src/components'; | ||
|
|
||
|  | ||
|
|
||
| ## Activities | ||
|
|
||
| - [Activity basics](/develop/dotnet/activities/basics) | ||
| - [Activity execution](/develop/dotnet/activities/execution) | ||
| - [Timeouts](/develop/dotnet/activities/timeouts) | ||
| - [Asynchronous Activity completion](/develop/dotnet/activities/asynchronous-activity) | ||
| - [Dynamic Activity](/develop/dotnet/activities/dynamic-activity) | ||
| - [Benign exceptions](/develop/dotnet/activities/benign-exceptions) | ||
|
|
||
| ### [Standalone Activities](/develop/dotnet/activities/standalone-activities) | ||
|
|
||
| Execute Activities independently without a Workflow using the Temporal Client. | ||
|
|
||
| - [How to execute a Standalone Activity](/develop/dotnet/activities/standalone-activities#execute-activity) | ||
| - [How to start a Standalone Activity without waiting](/develop/dotnet/activities/standalone-activities#start-activity) | ||
| - [How to get a handle to an existing Standalone Activity](/develop/dotnet/activities/standalone-activities#get-activity-handle) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.