var timer = new PeriodicTimer(TimeSpan.FromMinutes(5));
new Thread(async () =>
{
try
{
while (await timer.WaitForNextTickAsync().ConfigureAwait(false))
{
... do some things
}
}
catch (OperationCanceledException)
{
}
})
{
IsBackground = true,
}
.Start();
Every 5 minutes I have to do some things in the background thread. For some reason in some random time I get 300% cpu usage. Something wrong with my code? Thanks.