Created
May 10, 2022 21:03
-
-
Save rdelrosario/4b766638a39433dba726eded5617f954 to your computer and use it in GitHub Desktop.
StartupTaskSequencer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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