Open Source Web Application Framework for ASP.NET Core
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.
 
 
 
 
 
 

22 lines
751 B

using System;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.BackgroundWorkers;
using Volo.Abp.Threading;
namespace Volo.Abp.BackgroundJobs.DemoApp.TickerQ;
public class MyBackgroundWorker : AsyncPeriodicBackgroundWorkerBase
{
public MyBackgroundWorker([NotNull] AbpAsyncTimer timer, [NotNull] IServiceScopeFactory serviceScopeFactory) : base(timer, serviceScopeFactory)
{
timer.Period = 60 * 1000; // 60 seconds
CronExpression = "* * * * *"; // every minute
}
protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
{
Console.WriteLine($"MyBackgroundWorker executed at {DateTime.Now}");
}
}