Temporal .NET SDK Samples
April 29, 2026 ยท View on GitHub
This is the set of .NET samples for the .NET SDK.
Usage
Prerequisites:
Samples
- ActivityHeartbeatingCancellation - How to use heartbeating and cancellation handling in an activity.
- ActivitySimple - Simple workflow that runs simple activities.
- ActivityWorker - Use .NET activities from a workflow in another language.
- AspNet - Demonstration of a generic host worker and an ASP.NET workflow starter.
- Bedrock - Orchestrate a chatbot with Amazon Bedrock.
- ClientMtls - How to use client certificate authentication, e.g. for Temporal Cloud.
- ContextPropagation - Context propagation via interceptors.
- CounterInterceptor - Simple Workflow and Client Interceptors example.
- DependencyInjection - How to inject dependencies in activities and use generic hosts for workers
- Dsl - Workflow that interprets and executes workflow steps from a YAML-based DSL.
- EagerWorkflowStart - Demonstrates usage of Eager Workflow Start to reduce latency for workflows that start with a local activity.
- Encryption - End-to-end encryption with Temporal payload codecs.
- EnvConfig - Load client configuration from TOML files with programmatic overrides
- Mutex - How to implement a mutex as a workflow. Demonstrates how to avoid race conditions or parallel mutually exclusive operations on the same resource.
- NexusCancellation - Demonstrates how to cancel a running Nexus operation from a caller workflow.
- NexusContextPropagation - Context propagation through Nexus services.
- Nexus Messaging: Demonstrates how send signal, update and query messages through Nexus. This contains two samples, one sending messages to an existing workflow and a second that creates a workflow through Nexus and sends messages to it.
- NexusMultiArg - Nexus service implementation calling a workflow with multiple arguments.
- NexusSimple - Simple Nexus service implementation.
- OpenTelemetry - Demonstrates how to set up OpenTelemetry tracing and metrics for both the client and worker, using both the .NET metrics API and internal forwarding from the Core SDK.
- Patching - Alter workflows safely with Patch and DeprecatePatch.
- Polling - Recommended implementation of an activity that needs to periodically poll an external resource waiting its successful completion.
- SafeMessageHandlers - Use
Semaphoreto ensure operations are atomically processed in a workflow. - Saga - Demonstrates how to implement a saga pattern.
- Schedules - How to schedule workflows to be run at specific times in the future.
- SignalsQueries - A loyalty program using Signals and Queries.
- StandaloneActivity - Execute activities directly from a client, without a workflow.
- SleepForDays - Use a timer to send an email every 30 days.
- Timer - Use a timer to implement a monthly subscription; handle workflow cancellation.
- UpdatableTimer - A timer that can be updated while sleeping.
- UpdateWithStartEarlyReturn - Use update with start to get an early return, letting the rest of the workflow complete in the background.
- UpdateWithStartLazyInit - Use update with start to lazily start a workflow before sending update.
- WorkerSpecificTaskQueues - Use a unique task queue per Worker to have certain Activities only run on that specific Worker.
- WorkerVersioning - How to use the Worker Versioning feature to more easily deploy changes to Workflow & other code.
- WorkflowUpdate - How to use the Workflow Update feature while blocking in update method for concurrent updates.
Development
Code formatting
This project uses StyleCop analyzers with some overrides in .editorconfig. To format, run:
dotnet format
Can also run with --verify-no-changes to ensure it is formatted.
VisualStudio Code
When developing in vscode, the following JSON settings will enable StyleCop analyzers:
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableRoslynAnalyzers": true
Testing
Run:
dotnet test
Can add options like:
--logger "console;verbosity=detailed"to show logs--filter "FullyQualifiedName=TemporalioSamples.Tests.ActivityWorker.ActivityWorkerTests.Main_RunActivity_Succeeds"to run a specific test
There is also a standalone project for running tests so output is more visible. To use it, run
dotnet run --project tests/TemporalioSamples.Tests.csproj and can pass options after --, e.g. -- -verbose and/or
-- -method "*.RunAsync_SimpleRun_SucceedsAfterRetry".