I'm looking to modify an api method we currently use in our app. For some reason, when it gets called it fires off a long running thread. This allows for a quick response back to the client. I think that the manner in which this is done is incorrect to begin with. The second problem is that when the thread is running for ~ 2 hours it just stops.
Is there a way to dictate how long a thread stays alive for, or would it be better to use a task?
[HttpPost]
public void GenerateAndStore1095Cs(int tokenValue, int organizationId, int taxYear)
{
AuthenticateAndRecord(tokenValue, nameof(GenerateAndStore1095Cs), nameof(GenerateAndStore1095Cs), organizationId);
new Thread(() =>
{
PDFBusiness.GenerateAndStore1095Cs(organizationId, taxYear);
}).Start();
}