Skip to content

Instantly share code, notes, and snippets.

@jessicamilene
Last active January 23, 2024 10:15
Show Gist options
  • Save jessicamilene/67b9f3a1cab8089bb9fa2a5930e39ca5 to your computer and use it in GitHub Desktop.
Save jessicamilene/67b9f3a1cab8089bb9fa2a5930e39ca5 to your computer and use it in GitHub Desktop.
C# - Call an async method on the constructor

C#

Call an async method on the contructor and wait for it's execution

Task.Run(() => this.FunctionAsync()).Wait();
@jsanjuan2016
Copy link

This should also be considered: Task.Run(async () => await this.FunctionAsync());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment