Skip to content

Commit

Permalink
Add timer to repeat the check every 5 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
matteocontrini committed Mar 17, 2019
1 parent 19b0090 commit d0f1174
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion FibraClickSocial/Services/SchedulerHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SchedulerHostedService : IHostedService
private readonly CultureInfo culture = new CultureInfo("it-IT");

private const string FILE_PATH = "version.txt";
private const double CHECK_INTERVAL = 5 * 60 * 1000; // 5 minutes

public SchedulerHostedService(IWholesaleService wholesale,
ILogger<SchedulerHostedService> logger,
Expand All @@ -33,7 +34,17 @@ public SchedulerHostedService(IWholesaleService wholesale,
this.twitter = twitter;
}

public async Task StartAsync(CancellationToken cancellationToken)
public Task StartAsync(CancellationToken cancellationToken)
{
var t = new System.Timers.Timer();
t.Elapsed += Tick;
t.Interval = CHECK_INTERVAL;
t.Start();

return RunCheck();
}

private async void Tick(object sender, System.Timers.ElapsedEventArgs e)
{
await RunCheck();
}
Expand Down

0 comments on commit d0f1174

Please sign in to comment.