Skip to content

Instantly share code, notes, and snippets.

@gingters
Created April 26, 2022 18:26
Show Gist options
  • Save gingters/72788eab2cc09ae4a92f5b4e7c4662e9 to your computer and use it in GitHub Desktop.
Save gingters/72788eab2cc09ae4a92f5b4e7c4662e9 to your computer and use it in GitHub Desktop.
public async Task EnsureInitializedAsync()
{
if (_isInitialized) return;
if (_isInitializing && !_isInitialized)
{
do
{
await Task.Yield();
} while (!_isInitialized);
return;
}
_isInitializing = true;
// Do initialization here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment