Example #1
0
        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;
            }
            //}
        }
Example #2
0
        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");
        }
Example #3
0
 public static Task<AsyncClass1> CreateAsync()
 {
     var instance = new AsyncClass1();
     return instance.InitializeAsync();
 }
Example #4
0
        public static Task <AsyncClass1> CreateAsync()
        {
            var instance = new AsyncClass1();

            return(instance.InitializeAsync());
        }