User thread launched in Application_Start

I need to deal with an outdated ASP.NET application written in the .NET Framework 1.1. While checking the application code, I found the interesting part. The application starts its own thread in the Application_Start event handler (Global.asax). This thread should run the entire life of the application.

I read for a long time that this should never be used, but I don’t remember why. What are the problems associated with this application design? Is it possible to resume a flow upon failure? Will an alarm be recorded somewhere automatically (event log)? Can ASP.NET runtime kill a thread for any reason?

At the moment, I'm not interested in disposing of AppPool. It restarts the application, all sessions and creates a new thread.

+3
source share
1 answer

The main problem is that the thread may be interrupted at any time by ASP.NET. If a thread runs all the time, there is probably some work that it should do, and termination may not make your application happy the next time it starts.

Modern solutions include the use of asynchronous pages and an integrated thread pool.

If you decide to upgrade, remember that in .NET 1.1, threads throwing a top-level exception just exit; in .NET 2.0, threads throw a top-level exception crash . If you upgrade, it is probably best to leap for asynchronous pages rather than supporting a separate thread.

+2

Source: https://habr.com/ru/post/1763829/


All Articles