Reputation: 10403
I need reliable way to run 10 different tasks simultaneously. For instance the first one would be sending emails, while the next one is cleaning rows from a specific table... so on an so forth.
I've used the Thread class and while it works well on my development machine (VS2010 internal web server) non of these threads seems to be working at all on my production server. And I don't know of an effective way to debug the problem on the production server.
I saw this technique which encourage you to register cache objects. Since the application fires a callback when a cached item expires, then it's possible to run any code to mimic threading behavior. It seems a little Micky Mouse like.
I guess my questions is what is the correct way to indefinitely run background tasks in an ASP.NET MVC2 applications?
Upvotes: 3
Views: 304
Reputation: 8237
I have been using quartz.net for this before and it has worked out pretty well.
Upvotes: 1
Reputation: 33867
The best way is to not run them within ASP.net code. This sounds like an ideal task for a scheduled task, or a windows service. ASP.net (MVC or otherwise) is not really set up for doing this - split them out to a separate project.
Upvotes: 4
Reputation: 229284
There's certainly a lot of ways. Here's one.
Implement your long running tasks as a windows service , send messages about stuff-to-do to that service from your ASP.NET application using MSMQ,
Upvotes: 1