Last active
July 21, 2017 19:08
-
-
Save GeorgeTsiokos/5363976b4be53090bcf1785f5983d54b to your computer and use it in GitHub Desktop.
If you want a set-once static instance property, and for calling threads to block until it's set...
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
public static class ServiceLocator | |
{ | |
static readonly TaskCompletionSource<IContainer> __container = new TaskCompletionSource<IContainer>(); | |
public static IContainer Instance { | |
get => __container.Task.Result; | |
set => __container.SetResult(value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment