Fix naming of cancellation token

This commit is contained in:
Sipke Schoorstra 2022-03-21 19:29:49 +01:00
parent 4b9907b049
commit fee275ab26
5 changed files with 11 additions and 7 deletions

View file

@ -1,7 +1,8 @@
using System.Threading.Tasks;
using Elsa.Jobs.Contracts;
using Elsa.Jobs.Models;
namespace Elsa.Jobs.Contracts;
namespace Elsa.Jobs.Abstractions;
public abstract class Job : IJob
{

View file

@ -6,14 +6,14 @@ namespace Elsa.Jobs.Models;
public class JobExecutionContext
{
public JobExecutionContext(IServiceProvider serviceProvider, CancellationToken cancellation)
public JobExecutionContext(IServiceProvider serviceProvider, CancellationToken cancellationToken)
{
ServiceProvider = serviceProvider;
Cancellation = cancellation;
CancellationToken = cancellationToken;
}
public IServiceProvider ServiceProvider { get; }
public CancellationToken Cancellation { get; }
public CancellationToken CancellationToken { get; }
public T GetRequiredService<T>() where T : notnull => ServiceProvider.GetRequiredService<T>();
}

View file

@ -1,5 +1,6 @@
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Elsa.Jobs.Abstractions;
using Elsa.Models;
using Elsa.Runtime.Contracts;
using Elsa.Runtime.Models;
@ -28,6 +29,6 @@ public class ResumeWorkflowJob : Job
{
var request = new DispatchWorkflowInstanceRequest(WorkflowInstanceId, Bookmark);
var workflowInvoker = context.GetRequiredService<IWorkflowInvoker>();
await workflowInvoker.DispatchAsync(request, context.Cancellation);
await workflowInvoker.DispatchAsync(request, context.CancellationToken);
}
}

View file

@ -1,5 +1,6 @@
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Elsa.Jobs.Abstractions;
using Elsa.Runtime.Contracts;
using Elsa.Runtime.Models;
using Elsa.Jobs.Contracts;
@ -25,6 +26,6 @@ public class RunWorkflowJob : Job
{
var request = new DispatchWorkflowDefinitionRequest(WorkflowId, 1);
var workflowInvoker = context.GetRequiredService<IWorkflowInvoker>();
await workflowInvoker.DispatchAsync(request, context.Cancellation);
await workflowInvoker.DispatchAsync(request, context.CancellationToken);
}
}

View file

@ -3,6 +3,7 @@ using System.Net.Http;
using System.Threading.Tasks;
using Elsa.Activities.Primitives;
using Elsa.Contracts;
using Elsa.Jobs.Abstractions;
using Elsa.Jobs.Contracts;
using Elsa.Jobs.Models;
using Elsa.Runtime.Contracts;
@ -31,7 +32,7 @@ public class ReadTheInternetJob : Job
BaseAddress = new Uri("https://www.google.com")
};
var response = await httpClient.GetStringAsync("/", context.Cancellation);
var response = await httpClient.GetStringAsync("/", context.CancellationToken);
Console.WriteLine(response);
}
}