.NET | Durable Task SDK
Demonstrates the Monitor pattern using the Durable Task SDK. The orchestration periodically checks a simulated job status, sleeping between polls, until the job completes or a timeout is reached.
This pattern is useful for:
- Polling external APIs or services
- Waiting for long-running jobs to complete
- Implementing flexible timeouts with periodic checks
- .NET 8 SDK
- Docker (for the emulator)
-
Start the Durable Task Scheduler emulator:
docker run -d -p 8080:8080 -p 8082:8082 mcr.microsoft.com/dts/dts-emulator:latest
-
Start the worker (in one terminal):
cd Worker dotnet run -
Start the client (in another terminal):
cd Client dotnet run -
View orchestration progress in the dashboard: http://localhost:8082
- The orchestration starts monitoring a "job" with a unique ID
- Each iteration calls the
CheckJobStatusactivity to poll the job state - If the job is complete, the orchestration returns the result
- If not, it creates a durable timer to wait (e.g., 5 seconds) and then calls
ContinueAsNewto restart with updated state - A timeout guard prevents infinite polling