Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Core : ICore
- {
- private IScheduler scheduler;
- private readonly IConfiguration configuration;
- private static readonly TimeSpan defaultInterval = new TimeSpan(0,1,0);
- public Core(IConfiguration configuration)
- {
- this.configuration = configuration;
- }
- public async Task StartAsync()
- {
- var interval = configuration.GetValue("interval", defaultInterval);
- // Grab the Scheduler instance from the Factory
- NameValueCollection props = new NameValueCollection
- {
- { "quartz.serializer.type", "binary" }
- };
- StdSchedulerFactory factory = new StdSchedulerFactory(props);
- this.scheduler = await factory.GetScheduler();
- this.scheduler.JobFactory =new SimpleInjectorJobFactory(ContainerWrapper.Container, Assembly.GetExecutingAssembly());
- IJobDetail job = JobBuilder.Create<RinnovoJob>()
- .WithIdentity("RinnovoJob", "sender").StoreDurably(true)
- .Build();
- ITrigger trigger = TriggerBuilder.Create()
- .WithIdentity($"trigger_RinnovoJob", "sender")
- .StartNow().WithSimpleSchedule(x=>x.WithInterval(interval))
- .Build();
- // Tell quartz to schedule the job using our trigger
- await this.scheduler.ScheduleJob(job, trigger);
- // and start it off
- await this.scheduler.Start();
- }
- public void Dispose()
- {
- }
- }
- public class RinnovoJob:IJob
- {
- [omiss]
- public RinnovoJob([omiss])
- {
- [omiss]
- }
- public Task Execute(IJobExecutionContext context)
- {
- log.Info("Passed");
- return Task.CompletedTask;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement