mirror of https://github.com/abpframework/abp
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.
40 lines
1.0 KiB
40 lines
1.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using Volo.Abp.DependencyInjection;
|
|
using Volo.Abp.MultiTenancy;
|
|
using Volo.Abp.Threading;
|
|
|
|
namespace Volo.Abp.BackgroundJobs;
|
|
|
|
public class MyJob : BackgroundJob<MyJobArgs>, ISingletonDependency
|
|
{
|
|
public List<string> ExecutedValues { get; } = new List<string>();
|
|
|
|
public Guid? TenantId { get; set; }
|
|
|
|
private readonly ICurrentTenant _currentTenant;
|
|
private readonly ICancellationTokenProvider _cancellationTokenProvider;
|
|
|
|
public bool Canceled { get; set; }
|
|
|
|
public MyJob(
|
|
ICurrentTenant currentTenant,
|
|
ICancellationTokenProvider cancellationTokenProvider)
|
|
{
|
|
_currentTenant = currentTenant;
|
|
_cancellationTokenProvider = cancellationTokenProvider;
|
|
}
|
|
|
|
public override void Execute(MyJobArgs args)
|
|
{
|
|
if (_cancellationTokenProvider.Token.IsCancellationRequested)
|
|
{
|
|
Canceled = true;
|
|
}
|
|
|
|
ExecutedValues.Add(args.Value);
|
|
TenantId = _currentTenant.Id;
|
|
}
|
|
}
|