Files
Examples/GerstITS.Examples.Jobs.SayHelloWorld/Jobs/SayHelloWorldJob.cs
2022-12-22 15:29:53 +01:00

44 lines
1022 B
C#

using System.Diagnostics;
using System.Threading;
using GerstITS.Data;
using GerstITS.Examples.Jobs.SayHelloWorld.Configurations;
using GerstITS.Job;
using GerstITS.System.Environment;
using Quartz;
namespace GerstITS.Examples.Jobs.SayHelloWorld.Jobs;
[DisallowConcurrentExecution]
public class SayHelloWorldJob : JobBase
{
#region Fields
private readonly SayHelloWorldJobConfiguration _configuration;
private readonly Stopwatch _stopWatch;
#endregion
#region Cosntructors
public SayHelloWorldJob(SayHelloWorldJobConfiguration configuration,
ISystemClock systemClock)
{
_configuration = configuration;
_stopWatch = new Stopwatch();
}
#endregion
#region Methods
protected override void Execute()
{
_stopWatch.Restart();
Thread.Sleep(4000);
_stopWatch.Stop();
Debug.WriteLine($"---> Say hello to world from {_configuration.Name}, Duration: {_stopWatch.ElapsedMilliseconds / 1000}s");
}
#endregion
}