protected override async Task ExecuteAsync(CancellationToken stoppingToken) { //while (!stoppingToken.IsCancellationRequested) //{ logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); await Task.Delay(TimeSpan.FromSeconds(1), stoppingToken); var instance = await AsyncClass1.CreateAsync(); if (asyncClass2 is IAsyncInitialization instanceAsyncInit) { await instanceAsyncInit.Initialization; } //} }
private static async Task Init() { //Async Init await AsyncClass1.CreateAsync(); //Async Init Dependecy Injection Bootstrap.Register(); IAsyncClass2 instance2 = TinyIoCContainer.Current.Resolve <IAsyncClass2>(); var instanceAsyncInit = instance2 as IAsyncInitialization; if (instanceAsyncInit != null) { await instanceAsyncInit.Initialization; } Console.WriteLine("Initialization End"); }
public static Task<AsyncClass1> CreateAsync() { var instance = new AsyncClass1(); return instance.InitializeAsync(); }
public static Task <AsyncClass1> CreateAsync() { var instance = new AsyncClass1(); return(instance.InitializeAsync()); }