Skip to content

Instantly share code, notes, and snippets.

@GeorgeTsiokos
Last active July 21, 2017 19:08
Show Gist options
  • Save GeorgeTsiokos/5363976b4be53090bcf1785f5983d54b to your computer and use it in GitHub Desktop.
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...
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