Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Long Running Tasks - Best Practice - ASP.NET 4.0, C#

What is the recommended approach to dealing with process which take a long time to execute? I don't want to simply run it on the server since the page will time out.

I browsed the web and found multiple approaches - AJAX, Threading, Web Services... (none of which I have experience with)

What is the best practice method of dealing with this?

Thank you.

like image 402
Rivka Avatar asked Mar 06 '12 02:03

Rivka


1 Answers

If you're just trying to do a long-running task, a Windows Service is perfect for this. No, not a web service but an old-school Windows Service. When somebody uploads an Excel your Windows Service can be monitoring a directory using FileWatcher, and then execute the import process automatically. That way you aren't limiting your process to ASP.NET and the IIS Worker processes, which can be recycled for any number of reasons. It sounds like your app really needs to be outside of IIS. The upload process can be a simple web front end to put that file into that directory that is monitored by your Windows Service.

like image 85
Tim P. Avatar answered Oct 01 '22 08:10

Tim P.