mirror of https://github.com/abpframework/abp.git
committed by
GitHub
9 changed files with 125 additions and 7 deletions
@ -0,0 +1,20 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Logging.Abstractions; |
|||
|
|||
namespace Volo.Abp.BackgroundJobs |
|||
{ |
|||
public abstract class AsyncBackgroundJob<TArgs> : IAsyncBackgroundJob<TArgs> |
|||
{ |
|||
//TODO: Add UOW, Localization and other useful properties..?
|
|||
|
|||
public ILogger<AsyncBackgroundJob<TArgs>> Logger { get; set; } |
|||
|
|||
protected AsyncBackgroundJob() |
|||
{ |
|||
Logger = NullLogger<AsyncBackgroundJob<TArgs>>.Instance; |
|||
} |
|||
|
|||
public abstract Task ExecuteAsync(TArgs args); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.BackgroundJobs |
|||
{ |
|||
/// <summary>
|
|||
/// Defines interface of a background job.
|
|||
/// </summary>
|
|||
public interface IAsyncBackgroundJob<in TArgs> |
|||
{ |
|||
/// <summary>
|
|||
/// Executes the job with the <see cref="args"/>.
|
|||
/// </summary>
|
|||
/// <param name="args">Job arguments.</param>
|
|||
Task ExecuteAsync(TArgs args); |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.BackgroundJobs |
|||
{ |
|||
public class MyAsyncJob : AsyncBackgroundJob<MyAsyncJobArgs>, ISingletonDependency |
|||
{ |
|||
public List<string> ExecutedValues { get; } = new List<string>(); |
|||
|
|||
public override Task ExecuteAsync(MyAsyncJobArgs args) |
|||
{ |
|||
ExecutedValues.Add(args.Value); |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
namespace Volo.Abp.BackgroundJobs |
|||
{ |
|||
public class MyAsyncJobArgs |
|||
{ |
|||
public string Value { get; set; } |
|||
|
|||
public MyAsyncJobArgs() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public MyAsyncJobArgs(string value) |
|||
{ |
|||
Value = value; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue