From 14373bb559ce23b6be5dd39fea57c932a30d2a53 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 19 Apr 2022 11:33:03 +0800 Subject: [PATCH] Add notes to the `Module-Development-Basics` --- docs/en/Module-Development-Basics.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/en/Module-Development-Basics.md b/docs/en/Module-Development-Basics.md index 63cbc31893..17c0e91808 100644 --- a/docs/en/Module-Development-Basics.md +++ b/docs/en/Module-Development-Basics.md @@ -29,6 +29,8 @@ public class BlogModule : AbpModule ``ConfigureServices`` is the main method to add your services to the dependency injection system and configure other modules. Example: +> These methods have Async versions too, and if you want to make asynchronous calls inside these methods, override the asynchronous versions instead of the synchronous ones. + ````C# public class BlogModule : AbpModule { @@ -63,6 +65,8 @@ See the [Configuration](Configuration.md) document for more about the configurat ``AbpModule`` class also defines ``PreConfigureServices`` and ``PostConfigureServices`` methods to override and write your code just before and just after ``ConfigureServices``. Notice that the code you have written into these methods will be executed before/after the ``ConfigureServices`` methods of all other modules. +> These methods have Async versions too, and if you want to make asynchronous calls inside these methods, override the asynchronous versions instead of the synchronous ones. + ### Application Initialization Once all the services of all modules are configured, the application starts by initializing all modules. In this phase, you can resolve services from ``IServiceProvider`` since it's ready and available. @@ -71,10 +75,18 @@ Once all the services of all modules are configured, the application starts by i You can override ``OnApplicationInitialization`` method to execute code while application is being started. Example: +> These methods have Async versions too, and if you want to make asynchronous calls inside these methods, override the asynchronous versions instead of the synchronous ones. + ````C# public class BlogModule : AbpModule { - //... + // Asynchronous methods call synchronous methods by default, You only need to implement one of them. + + public override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) + { + var myService = context.ServiceProvider.GetService(); + await myService.DoSomethingAsync(); + } public override void OnApplicationInitialization(ApplicationInitializationContext context) {