Skip to content

Commit e0500f5

Browse files
committed
Extend RunWorkflowSync
Extend RunWorkflowSync using a CancelationToken
1 parent 24f05e3 commit e0500f5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/WorkflowCore/Interface/ISyncWorkflowRunner.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Threading;
23
using System.Threading.Tasks;
34
using WorkflowCore.Models;
45

@@ -8,5 +9,8 @@ public interface ISyncWorkflowRunner
89
{
910
Task<WorkflowInstance> RunWorkflowSync<TData>(string workflowId, int version, TData data, string reference, TimeSpan timeOut, bool persistSate = true)
1011
where TData : new();
12+
13+
Task<WorkflowInstance> RunWorkflowSync<TData>(string workflowId, int version, TData data, string reference, CancellationToken token, bool persistSate = true)
14+
where TData : new();
1115
}
1216
}

src/WorkflowCore/Services/SyncWorkflowRunner.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ public SyncWorkflowRunner(IWorkflowHost host, IWorkflowExecutor executor, IDistr
3232
_dateTimeProvider = dateTimeProvider;
3333
}
3434

35-
public async Task<WorkflowInstance> RunWorkflowSync<TData>(string workflowId, int version, TData data, string reference, TimeSpan timeOut, bool persistSate = true)
35+
public Task<WorkflowInstance> RunWorkflowSync<TData>(string workflowId, int version, TData data,
36+
string reference, TimeSpan timeOut, bool persistSate = true)
37+
where TData : new()
38+
{
39+
return RunWorkflowSync(workflowId, version, data, reference, new CancellationTokenSource(timeOut).Token,
40+
persistSate);
41+
}
42+
43+
public async Task<WorkflowInstance> RunWorkflowSync<TData>(string workflowId, int version, TData data, string reference, CancellationToken token, bool persistSate = true)
3644
where TData : new()
3745
{
3846
var def = _registry.GetDefinition(workflowId, version);

0 commit comments

Comments
 (0)