Should I use a Windows service or ASP.NET background thread?

I am writing a web application in ASP.NET 3.5 that deals with some basic data entry scenarios. The application also includes a component that must constantly poll some data and perform actions based on business logic.

What is the best way to implement the polling component? It should run and check data every couple of minutes or so.

In the past, I saw several different options:

  • The web application launches a background thread that will always execute while the web application is running. (The implementation I saw started the thread in the Application_Start event.)
  • Create a Windows service that always works

What are the benefits of one of these options? Are there any additional options?

I am inclined towards the Windows service because it is split up and can work on another server (more scalable), as well as more control over its start / stop, etc. However, I feel that the compactness of having “background” logic running in the process of a web application can make the whole solution more understandable.

+5
source share
4 answers

I would go to a separate Windows service first of all for the reasons you give:

  • If necessary, you can run it on another server.
  • You can start and stop it regardless of the website.

I would also add that this can affect the performance of the website itself - something you want to avoid.

- " ". - , .

- , .

Windows , , , , . - , , .

, , , , , .

+6

, ui? , Windows, . Windows, .

+2

, SQL Server , .

+1

. TAPI, . , GCed .

0

All Articles