You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/modules/background-jobs/app/Volo.Abp.BackgroundJobs.Dem.../Jobs/SampleJobCreator.cs

30 lines
1.1 KiB

using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Threading;
namespace Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs
{
public class SampleJobCreator : ITransientDependency
{
private readonly IBackgroundJobManager _backgroundJobManager;
public SampleJobCreator(IBackgroundJobManager backgroundJobManager)
{
_backgroundJobManager = backgroundJobManager;
}
public void CreateJobs()
{
AsyncHelper.RunSync(CreateJobsAsync);
}
public async Task CreateJobsAsync()
{
await _backgroundJobManager.EnqueueAsync(new WriteToConsoleGreenJobArgs { Value = "test 1 (green)" }).ConfigureAwait(false);
await _backgroundJobManager.EnqueueAsync(new WriteToConsoleGreenJobArgs { Value = "test 2 (green)" }).ConfigureAwait(false);
await _backgroundJobManager.EnqueueAsync(new WriteToConsoleYellowJobArgs { Value = "test 1 (yellow)" }).ConfigureAwait(false);
await _backgroundJobManager.EnqueueAsync(new WriteToConsoleYellowJobArgs { Value = "test 2 (yellow)" }).ConfigureAwait(false);
}
}
}