-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathMyWorkflow.workflow.cs
More file actions
43 lines (33 loc) · 1.09 KB
/
MyWorkflow.workflow.cs
File metadata and controls
43 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
namespace TemporalioSamples.CounterInterceptor;
using Temporalio.Workflows;
[Workflow]
public class MyWorkflow
{
private bool exit; // Automatically defaults to false
[WorkflowRun]
public async Task<string> RunAsync()
{
// Wait for greeting info
await Workflow.WaitConditionAsync(() =>
!string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Title));
// Execute Child Workflow
var result = await Workflow.ExecuteChildWorkflowAsync(
(MyChildWorkflow wf) => wf.RunAsync(Name, Title),
new() { Id = "counter-interceptor-child" });
// Wait for exit signal
await Workflow.WaitConditionAsync(() => exit);
return result;
}
[WorkflowSignal]
public async Task SignalNameAndTitleAsync(string name, string title)
{
Name = name;
Title = title;
}
[WorkflowQuery]
public string Name { get; private set; } = string.Empty;
[WorkflowQuery]
public string Title { get; private set; } = string.Empty;
[WorkflowSignal]
public async Task ExitAsync() => exit = true;
}