Created
January 4, 2015 03:39
-
-
Save scionwest/8f919253b9a3993b9f6c 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
| private List<Func<Task>> ShutdownCallbacks = new List<Func<Task>>(); | |
| public void RegisterShutdownCallback(Func<Task> callback) | |
| { | |
| this.ShutdownCallbacks.Add(callback); | |
| } | |
| public async Task Shutdown() | |
| { | |
| var callbackTasks = new List<Task>(); | |
| foreach(var callback in this.ShutdownCallbacks) | |
| { | |
| callbackTasks.Add(callback()); | |
| } | |
| await Task.WhenAll(callbackTasks); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment