Answer the question
In order to leave comments, you need to log in
ASP.Net Creepy mystique with ThreadAbortException?
Hi all,
I don’t want to go into details too much, the essence of the question is this, I have a very heavy function that writes a lot to a file, about a gig or more, this whole operation takes several minutes. And before, everything was fine when the whole thing was done in the context of the request. But as soon as I decided to do it asynchronously in order to log the execution of the task, I was pleasantly surprised that IIS nailed my task even with cancer, even before. Those. I used both Task.Run and manually created the thread, and IIS is all below the eggs, it nails everything. I just think, well, how ... this can be done, I would tear the hands of MS programmers. In general, 10 hours of debugging nichrome did not give a result, it just crashes anywhere, I thought maybe there was some kind of error, but no, it's just random and that's it. The only thing that was found out that just before ThreadAbortException occurs Application_End in Global.asax.cs . Maybe there is not enough memory, maybe something else, but it's not clear why everything works in the context of the request. Who faced a similar problem, and how to make the thread with my mega super important task unkillable?
Found the answer to my question here:
haacked.com/archive/2011/10/16/the-dangers-of-impl...
In short, ASP.NET does not like long tasks, and tasks caused by non-requests are just for white people does not count and kills them like insects... I hope the situation in vNext will be different.
Answer the question
In order to leave comments, you need to log in
I agree with Vasily , but if you really want to, then .NET 4.5.2 has HostingEnvironment.QueueBackgroundWorkItem .
I agree with Vasily 100%. Moreover, on shared hosting, you will not be allowed to perform heavy tasks in the context of the request. And even QueueBackgroundWorkItem will hardly help you. And this will not be fixed in vNext or any other version of .NET. You will also hammer a nail with an ammeter and a voltmeter - you don’t know how to use a hammer, hire someone who can.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question