diff --git a/docs/en/Background-Workers-Hangfire.md b/docs/en/Background-Workers-Hangfire.md index 4cbaf8cc24..b076cf0395 100644 --- a/docs/en/Background-Workers-Hangfire.md +++ b/docs/en/Background-Workers-Hangfire.md @@ -95,29 +95,29 @@ public class MyLogWorker : HangfireBackgroundWorkerBase, IMyLogWorker ## Register BackgroundWorkerManager -After creating a background worker class, you should add it to the `IBackgroundWorkerManager`. The most common place is the `OnApplicationInitialization` method of your module class: +After creating a background worker class, you should add it to the `IBackgroundWorkerManager`. The most common place is the `OnApplicationInitializationAsync` method of your module class: ```` csharp [DependsOn(typeof(AbpBackgroundWorkersModule))] public class MyModule : AbpModule { - public override void OnApplicationInitialization( + public override async Task OnApplicationInitializationAsync( ApplicationInitializationContext context) { - context.AddBackgroundWorker(); + await context.AddBackgroundWorkerAsync(); //If the interface is defined - //context.AddBackgroundWorker(); + //await context.AddBackgroundWorkerAsync(); } } ```` -`context.AddBackgroundWorker(...)` is a shortcut extension method for the expression below: +`context.AddBackgroundWorkerAsync(...)` is a shortcut extension method for the expression below: ```` csharp context.ServiceProvider .GetRequiredService() - .Add( + .AddAsync( context .ServiceProvider .GetRequiredService() @@ -126,4 +126,4 @@ context.ServiceProvider So, it resolves the given background worker and adds to the `IBackgroundWorkerManager`. -While we generally add workers in OnApplicationInitialization, there are no restrictions on that. You can inject IBackgroundWorkerManager anywhere and add workers at runtime. Background worker manager will stop and release all the registered workers when your application is being shut down. +While we generally add workers in `OnApplicationInitializationAsync`, there are no restrictions on that. You can inject `IBackgroundWorkerManager` anywhere and add workers at runtime. Background worker manager will stop and release all the registered workers when your application is being shut down. diff --git a/docs/en/Background-Workers.md b/docs/en/Background-Workers.md index e1cce6ae28..286d6ab7b0 100644 --- a/docs/en/Background-Workers.md +++ b/docs/en/Background-Workers.md @@ -80,16 +80,16 @@ public class PassiveUserCheckerWorker : AsyncPeriodicBackgroundWorkerBase ## Register Background Worker -After creating a background worker class, you should add it to the `IBackgroundWorkerManager`. The most common place is the `OnApplicationInitialization` method of your module class: +After creating a background worker class, you should add it to the `IBackgroundWorkerManager`. The most common place is the `OnApplicationInitializationAsync` method of your module class: ````csharp [DependsOn(typeof(AbpBackgroundWorkersModule))] public class MyModule : AbpModule { - public override Task OnApplicationInitializationAsync( + public override async Task OnApplicationInitializationAsync( ApplicationInitializationContext context) { - context.AddBackgroundWorkerAsync(); + await context.AddBackgroundWorkerAsync(); } } ```` @@ -108,7 +108,7 @@ await context.ServiceProvider So, it resolves the given background worker and adds to the `IBackgroundWorkerManager`. -While we generally add workers in `OnApplicationInitialization`, there are no restrictions on that. You can inject `IBackgroundWorkerManager` anywhere and add workers at runtime. Background worker manager will stop and release all the registered workers when your application is being shut down. +While we generally add workers in `OnApplicationInitializationAsync`, there are no restrictions on that. You can inject `IBackgroundWorkerManager` anywhere and add workers at runtime. Background worker manager will stop and release all the registered workers when your application is being shut down. ## Options diff --git a/docs/zh-Hans/Background-Workers-Hangfire.md b/docs/zh-Hans/Background-Workers-Hangfire.md index 5e53928ca1..b02a793d3f 100644 --- a/docs/zh-Hans/Background-Workers-Hangfire.md +++ b/docs/zh-Hans/Background-Workers-Hangfire.md @@ -96,29 +96,29 @@ public class MyLogWorker : HangfireBackgroundWorkerBase, IMyLogWorker ## 注册到后台工作者管理器 -创建一个后台工作者后, 你应该添加到 `IBackgroundWorkerManager`, 最常用的地方是在你模块类的 `OnApplicationInitialization` 方法中: +创建一个后台工作者后, 你应该添加到 `IBackgroundWorkerManager`, 最常用的地方是在你模块类的 `OnApplicationInitializationAsync` 方法中: ```` csharp [DependsOn(typeof(AbpBackgroundWorkersModule))] public class MyModule : AbpModule { - public override void OnApplicationInitialization( + public override async Task OnApplicationInitializationAsync( ApplicationInitializationContext context) { - context.AddBackgroundWorker(); + await context.AddBackgroundWorkerAsync(); //如果定义了接口 - //context.AddBackgroundWorker(); + //await context.AddBackgroundWorkerAsync(); } } ```` -`context.AddBackgroundWorker(...)` 是一个是以下代码快捷的扩展方法: +`context.AddBackgroundWorkerAsync(...)` 是一个是以下代码快捷的扩展方法: ```` csharp context.ServiceProvider .GetRequiredService() - .Add( + .AddAsync( context .ServiceProvider .GetRequiredService() @@ -127,4 +127,4 @@ context.ServiceProvider 它解析给定的后台工作者并添加到 `IBackgroundWorkerManager`. -虽然我们通常在 `OnApplicationInitialization` 中添加后台工作者, 但对此没有限制. 你可以在任何地方注入 `IBackgroundWorkerManager` 并在运行时添加后台工作者. \ No newline at end of file +虽然我们通常在 `OnApplicationInitializationAsync` 中添加后台工作者, 但对此没有限制. 你可以在任何地方注入 `IBackgroundWorkerManager` 并在运行时添加后台工作者. \ No newline at end of file diff --git a/docs/zh-Hans/Background-Workers.md b/docs/zh-Hans/Background-Workers.md index 3f0e7fb369..da1e9f9f54 100644 --- a/docs/zh-Hans/Background-Workers.md +++ b/docs/zh-Hans/Background-Workers.md @@ -78,26 +78,26 @@ public class PassiveUserCheckerWorker : AsyncPeriodicBackgroundWorkerBase ## 注册后台工作者 -创建一个后台工作者后,你应该将其添加到 `IBackgroundWorkerManager`. 最常见的地方是模块类的 `OnApplicationInitialization` 方法: +创建一个后台工作者后,你应该将其添加到 `IBackgroundWorkerManager`. 最常见的地方是模块类的 `OnApplicationInitializationAsync` 方法: ````csharp [DependsOn(typeof(AbpBackgroundWorkersModule))] public class MyModule : AbpModule { - public override void OnApplicationInitialization( + public override async Task OnApplicationInitialization( ApplicationInitializationContext context) { - context.AddBackgroundWorker(); + await context.AddBackgroundWorkerAsync(); } } ```` -`context.AddBackgroundWorker(...)` 是以下代码的简化扩展方法: +`context.AddBackgroundWorkerAsync(...)` 是以下代码的简化扩展方法: ````csharp context.ServiceProvider .GetRequiredService() - .Add( + .AddAsync( context .ServiceProvider .GetRequiredService() @@ -106,7 +106,7 @@ context.ServiceProvider 所以,它解析了给定的后台工作者并添加到 `IBackgroundWorkerManager`. -如果我们通常在 `OnApplicationInitialization` 添加工作者,但并不是强制的. 你可以在应用程序的任何地方注入 `IBackgroundWorkerManager` 并在运行时添加工作者. 在你的应用程序关闭时Background worker manager会释放所有已注册的后台工作者. +如果我们通常在 `OnApplicationInitializationAsync` 添加工作者,但并不是强制的. 你可以在应用程序的任何地方注入 `IBackgroundWorkerManager` 并在运行时添加工作者. 在你的应用程序关闭时Background worker manager会释放所有已注册的后台工作者. ## Options