elsa-core/src/samples/console/Elsa.Samples.WhileLoopConsole/Program.cs

31 lines
1 KiB
C#

using System.Threading.Tasks;
using Elsa.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Samples.WhileLoopConsole
{
/// <summary>
/// Demonstrates a workflow with a While looping construct.
/// </summary>
internal static class Program
{
private static async Task Main()
{
// Create a service container with Elsa services.
var services = new ServiceCollection()
.AddElsa(options => options
.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.
var workflowRunner = services.GetRequiredService<IBuildsAndStartsWorkflow>();
// Execute the workflow.
await workflowRunner.BuildAndStartWorkflowAsync(new WhileLoopWorkflow(3));
}
}
}