IBackgroundJobManager.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Threading.Tasks;
  3. using Abp.Threading.BackgroundWorkers;
  4. namespace Abp.BackgroundJobs
  5. {
  6. //TODO: Create a non-generic EnqueueAsync extension method to IBackgroundJobManager which takes types as input parameters rather than generic parameters.
  7. /// <summary>
  8. /// Defines interface of a job manager.
  9. /// </summary>
  10. public interface IBackgroundJobManager : IBackgroundWorker
  11. {
  12. /// <summary>
  13. /// Enqueues a job to be executed.
  14. /// </summary>
  15. /// <typeparam name="TJob">Type of the job.</typeparam>
  16. /// <typeparam name="TArgs">Type of the arguments of job.</typeparam>
  17. /// <param name="args">Job arguments.</param>
  18. /// <param name="priority">Job priority.</param>
  19. /// <param name="delay">Job delay (wait duration before first try).</param>
  20. /// <returns>Unique identifier of a background job.</returns>
  21. Task<string> EnqueueAsync<TJob, TArgs>(TArgs args, BackgroundJobPriority priority = BackgroundJobPriority.Normal, TimeSpan? delay = null)
  22. where TJob : IBackgroundJob<TArgs>;
  23. /// <summary>
  24. /// Deletes a job with the specified jobId.
  25. /// </summary>
  26. /// <param name="jobId">The Job Unique Identifier.</param>
  27. /// <returns><c>True</c> on a successfull state transition, <c>false</c> otherwise.</returns>
  28. Task<bool> DeleteAsync(string jobId);
  29. }
  30. }