I need to call a very slow database method from a web page. It seems I have lots of options ranging from using BackgroundWorker, Task.Run() and Thread.Start()
Which is most appropriate for my scenario?
Currently I have:
Task.Run(() =>
{
using (DAL.StatsDAL data = new DAL.StatsDAL())
{
data.UpdateStatistics(entryID, entryTtype);
}
});
I do not need a result from this (currently) but I just need to "fire and forget". Also I'm guessing any potential error messages which occur on this thread will not get caught by my exception handler (ELMAH) as the HttpContext might have disappeared by then?
Edit: This is ASP.NET WebForms 4.5.1.
Edit 2: I expect the task to complete in around 1 second (max), so I'm really just trying to avoid the 1 second delay every time the user clicks between pages