Created
May 10, 2022 01:27
-
-
Save rdelrosario/092ea6400d84ce46a026f20eb975c9e3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class StartupTaskBuilder | |
{ | |
... | |
private class StartupTaskSequencer : IStartupTaskSequencer | |
{ | |
public StartupTaskSequencer(Queue<IStartupTask> tasks) => _tasks = tasks; | |
public async Task StartAsync(IStartupTask task) | |
{ | |
foreach (var next in _tasks.SkipWhile(x => x != task)) | |
{ | |
if (await next.CanRunAsync()) | |
{ | |
await next.RunAsync(); | |
} | |
} | |
} | |
public Task StartAsync() => StartAsync(_tasks.FirstOrDefault()); | |
private readonly Queue<IStartupTask> _tasks; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment