Skip to content

Instantly share code, notes, and snippets.

@rdelrosario
Created May 10, 2022 21:03
Show Gist options
  • Save rdelrosario/4b766638a39433dba726eded5617f954 to your computer and use it in GitHub Desktop.
Save rdelrosario/4b766638a39433dba726eded5617f954 to your computer and use it in GitHub Desktop.
StartupTaskSequencer.cs
private class StartupTaskSequencer : IStartupTaskSequencer
{
public StartupTaskSequencer(Queue<IStartupTask> tasks) => _tasks = tasks;
public async Task StartAsync(IStartupTask task, IStartupTaskParameters parameters = null)
{
parameters ??= StartupTaskParameters.None;
foreach (var next in _tasks.SkipWhile(x => x != task))
{
if (await next.CanRunAsync())
{
parameters = await next.RunAsync(parameters);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment