简体   繁体   中英

Managing Long Running Processes in ASP.Net MVC5

I am developing an MVC application in which there are several long running processes. In this MVC app I am trying to pull the friends from facebook and stored in mongoDB.

The steps for this process are as follows:-

  1. Pull the friends for a user from database in a generic list object.
  2. Pull the friends for a user from facebook in another generic list object.
  3. Identify new friends which are not in database.
  4. For existing friends run a loop and update the existing data.
  5. Store the new friends in database.There is a

This works fine if their are around 50 to 100 friends. But if there are 1000+ friends then the web page takes around 30+ minutes to execute them. For executing this process I am using Task with async and await. I am calling controller action by jquery AJAX.

So my problem is if their are 2000+ records then it takes too much time. So after studying the thing I wanted to use window service for extracting data from facebook. However I'm still exploring option so that I have not use window service.

Regarding using window service I have some questions beow:-

  1. How to start a window service from ASP.Net MVC.
  2. If I can pass arguments in window service from ASP.Net MVC controller.
  3. If window service will stop automatically completion of the task or I need to stop it from web page.
  4. if window service can be accessed from ASP.Net MVC app in window azure as it will hosted in Azure.
  5. Is their is any security issue when accessing window service from MVC in Azure.

Sorry for too many questions. I have used Window Service earlier but it scheduled with time. So accessing from ASP.Net is new for me.

I have find an article http://weblogs.asp.net/kaushal/start-stop-window-service-from-asp-net-page but it does not provide all the answer of my question.

Please help me in this regard. Thanks in advance.

Why would you want to start/stop the service from ASP.Net? It is a windows service, let it run periodically with say every day or whatever frequency you want and let it do the job or reading/writing database and merging contracts from facebook. Why does is it even an ASP.Net App, if that is all it does.?

Maybe I am missing something, but you do not need to interact with windows service from your web application. All you need to do is query the database. Let the service sync the FB contacts to MongoDB in the background periodically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM