Browse Source

Update DemoApp

pull/15282/head
ahmetfarukulu 4 years ago
parent
commit
97f852f454
  1. 12
      modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/LongRunningJob.cs
  2. 2
      modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleGreenJob.cs
  3. 2
      modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleYellowJob.cs

12
modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/LongRunningJob.cs

@ -1,12 +1,20 @@
using System; using System;
using System.Threading; using System.Threading;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Threading;
namespace Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs namespace Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs
{ {
public class LongRunningJob : BackgroundJob<LongRunningJobArgs>, ITransientDependency public class LongRunningJob : BackgroundJob<LongRunningJobArgs>, ITransientDependency
{ {
public override void Execute(LongRunningJobArgs args, CancellationToken cancellationToken = default) private readonly ICancellationTokenProvider _cancellationTokenProvider;
public LongRunningJob(ICancellationTokenProvider cancellationTokenProvider)
{
_cancellationTokenProvider = cancellationTokenProvider;
}
public override void Execute(LongRunningJobArgs args)
{ {
lock (Console.Out) lock (Console.Out)
{ {
@ -17,7 +25,7 @@ namespace Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs
for (var i = 1; i <= 10; i++) for (var i = 1; i <= 10; i++)
{ {
cancellationToken.ThrowIfCancellationRequested(); _cancellationTokenProvider.Token.ThrowIfCancellationRequested();
Thread.Sleep(1000); Thread.Sleep(1000);
Console.WriteLine($"{args.Value} step-{i} done: {DateTime.Now}"); Console.WriteLine($"{args.Value} step-{i} done: {DateTime.Now}");

2
modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleGreenJob.cs

@ -6,7 +6,7 @@ namespace Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs
{ {
public class WriteToConsoleGreenJob : BackgroundJob<WriteToConsoleGreenJobArgs>, ITransientDependency public class WriteToConsoleGreenJob : BackgroundJob<WriteToConsoleGreenJobArgs>, ITransientDependency
{ {
public override void Execute(WriteToConsoleGreenJobArgs args, CancellationToken cancellationToken = default) public override void Execute(WriteToConsoleGreenJobArgs args)
{ {
if (RandomHelper.GetRandom(0, 100) < 70) if (RandomHelper.GetRandom(0, 100) < 70)
{ {

2
modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleYellowJob.cs

@ -6,7 +6,7 @@ namespace Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs
{ {
public class WriteToConsoleYellowJob : BackgroundJob<WriteToConsoleYellowJobArgs>, ITransientDependency public class WriteToConsoleYellowJob : BackgroundJob<WriteToConsoleYellowJobArgs>, ITransientDependency
{ {
public override void Execute(WriteToConsoleYellowJobArgs args, CancellationToken cancellationToken = default) public override void Execute(WriteToConsoleYellowJobArgs args)
{ {
if (RandomHelper.GetRandom(0, 100) < 70) if (RandomHelper.GetRandom(0, 100) < 70)
{ {

Loading…
Cancel
Save