elsa-core/src/modules/Elsa.Scheduling/Tasks/DelegateTask.cs
Sipke Schoorstra 7a09944732
Refactor scheduling and background activity execution (#3884)
* Refactor background activity execution

* Refactor scheduler

* Remove Jobs module

* Add XML comments
2023-04-09 23:35:32 +02:00

23 lines
693 B
C#

using Elsa.Scheduling.Contracts;
using Elsa.Scheduling.Models;
using JetBrains.Annotations;
namespace Elsa.Scheduling.Tasks;
/// <summary>
/// A generic task that executes the provided delegate.
/// </summary>
[PublicAPI]
public class DelegateTask : ITask
{
private readonly Func<TaskExecutionContext, ValueTask> _task;
/// <summary>
/// Initializes a new instance of the <see cref="DelegateTask"/> class.
/// </summary>
/// <param name="task">The delegate to execute.</param>
public DelegateTask(Func<TaskExecutionContext, ValueTask> task) => _task = task;
/// <inheritdoc />
public ValueTask ExecuteAsync(TaskExecutionContext context) => _task(context);
}