Simplify .NET worker execution example

This commit is contained in:
Brian Strauch
2026-08-20 12:00:40 -07:00
parent 4394ec9140
commit 83b883601a
+1 -8
View File
@@ -59,20 +59,13 @@ using Temporalio.Worker;
var client = await TemporalClient.ConnectAsync(new("localhost:7233"));
using var tokenSource = new CancellationTokenSource();
Console.CancelKeyPress += (_, eventArgs) =>
{
tokenSource.Cancel();
eventArgs.Cancel = true;
};
using var worker = new TemporalWorker(
client,
new TemporalWorkerOptions("my-task-queue")
.AddWorkflow<GreetingWorkflow>()
.AddAllActivities(new MyActivities()));
await worker.ExecuteAsync(tokenSource.Token);
await worker.ExecuteAsync(() => Task.Delay(Timeout.Infinite));
```
**Start the dev server:** Start `temporal server start-dev` in the background.