I have a task which I fire off to do some periodic work, although I've noticed it randomly stops executing.
Task.Factory.StartNew(gameProcessor.ProcessAsync, CancellationToken.None,
TaskCreationOptions.LongRunning, TaskScheduler.Default);
I understand I'm not awaiting the task but I have implemented a try catch block for error handling. Even with this I can confirm my breakpoint never hits the catch statement, so I'm confused to what's going on.
Method:
public async Task ProcessAsync()
{
while (true)
{
try
{
await _roomRepository.RunPeriodicCheckAsync();
await Task.Delay(500);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}