static async Task RunAsyncFactoryMethod() { //code without factory - coder may not call InitAsync, which is not good // var foo = new Foo(); // await foo.InitAsync(); //using factory method var foo = await Foo.CreateAsync("Kevin"); System.Console.WriteLine(foo); }
public static async Task Main(string[] args) { //var foo = new Foo(); //await foo.InitAsync(); Foo x = await Foo.CreateAsync(); }
// change to Main to run. public static async Task none(string[] args) { // client that uses the API only gets to initialize the object fully // and does it in an asynchronous manner. Foo x = await Foo.CreateAsync(); }