Browse Source

Update Background-Jobs-Hangfire.md

Add requested changes in documentation.
pull/3233/head
suravi999 7 years ago
committed by GitHub
parent
commit
0e70f9e9b6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      docs/en/Background-Jobs-Hangfire.md

26
docs/en/Background-Jobs-Hangfire.md

@ -43,7 +43,7 @@ You can install any storage for Hangfire. The most common one is SQL Server (see
After you have installed these NuGet packages, you need to configure your project to use Hangfire.
1.First, we change the `<YourProjectName>HttpApiHostModule` class to add Hangfire configuration of the storage and connection string in the `ConfigureServices` method:
1.First, we change the `Module` class (example: `<YourProjectName>HttpApiHostModule`) to add Hangfire configuration of the storage and connection string in the `ConfigureServices` method:
````csharp
@ -61,28 +61,24 @@ After you have installed these NuGet packages, you need to configure your projec
{
context.Services.AddHangfire(config =>
{
config.UsePostgreSqlStorage(configuration.GetConnectionString("Default"));
config.UseSqlServerStorage(configuration.GetConnectionString("Default"));
});
}
````
2. We need to add `UseHangfireServer` call in the Configure method in `Startup` class
2. We need to add `UseHangfireServer` call in the `OnApplicationInitialization` method in `Module` class
If you want to use hangfire's dashboard, you can add it, too: by `UseHangfireDashboard`
````csharp
public class Startup
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<IOSampleAngulerHttpApiHostModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
app.UseHangfireServer();
app.UseHangfireDashboard();
}
var app = context.GetApplicationBuilder();
// ... others
app.UseHangfireServer();
app.UseHangfireDashboard();
}
````

Loading…
Cancel
Save