Hi,
I have a service that do some work with a polling intervall.
Task task = new Task( delegate { DoWork(); });
task.Wait(Convert.ToInt32(ConfigurationManager.AppSettings["PollingInterval"]));
task.RunSynchronously();
My question is how to abort the Task safe?
Is it enough with
try
{
Task task = new Task( delegate { DoWork(); });
task.Wait(Convert.ToInt32(ConfigurationManager.AppSettings["PollingInterval"]));
task.RunSynchronously();
}
catch (ThreadAbortException threadAbortException)
{
// Clean up
}

Amit GuptaRank #190 · 12.8K reputationPosted Feb 26, 2021, 2:46 AM EST
Amit GuptaRank #190 · 12.8K reputationPosted Feb 26, 2021, 4:43 AM EST