2020-12-11 20:03:49 +00:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
using Elsa.Persistence.InMemory;
|
2020-10-29 08:24:02 +00:00
|
|
|
using Elsa.Services;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
namespace Elsa.Samples.WhileLoopConsole
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Demonstrates a workflow with a While looping construct.
|
|
|
|
|
/// </summary>
|
2020-12-12 13:07:17 +00:00
|
|
|
internal static class Program
|
2020-10-29 08:24:02 +00:00
|
|
|
{
|
|
|
|
|
private static async Task Main()
|
|
|
|
|
{
|
|
|
|
|
// Create a service container with Elsa services.
|
|
|
|
|
var services = new ServiceCollection()
|
|
|
|
|
.AddElsa()
|
|
|
|
|
.AddConsoleActivities()
|
|
|
|
|
.BuildServiceProvider();
|
|
|
|
|
|
|
|
|
|
// Run startup actions (not needed when registering Elsa with a Host).
|
|
|
|
|
var startupRunner = services.GetRequiredService<IStartupRunner>();
|
|
|
|
|
await startupRunner.StartupAsync();
|
|
|
|
|
|
|
|
|
|
// Get a workflow runner.
|
2020-11-27 20:47:51 +00:00
|
|
|
var workflowRunner = services.GetRequiredService<IWorkflowRunner>();
|
2020-10-29 08:24:02 +00:00
|
|
|
|
|
|
|
|
// Execute the workflow.
|
2020-10-29 10:42:13 +00:00
|
|
|
await workflowRunner.RunWorkflowAsync(new WhileLoopWorkflow(3));
|
2020-10-29 08:24:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|