Friday, January 4, 2019

What's the best way to have a long running process continue in the background on the server side independent from the user's interaction?

To give some context, I'm working on a site that deals with a lot of uploading and downloading of files. Most of the files being uploaded are small, but I want to take a lot of these files and compress them in a .zip for download. I understand the user could just upload a .zip but there's a specific reason for it to function this way. The issue is that I want the user to be able to put in the request for the .zip, but I don't want that entire process to be contained in that one request. It'd require pulling the files from the database, converting them, putting them into a folder and then compressing them, and I want the user to be able to continue using the application (like go back to the home page, or just continue navigating in general) as all of that goes on the background. So, it'd be something like:

​

[HttpPost] [Route("CreateZip")] public IActionResult CreateZip(string name, List<int> SelectedFiles) { //And then some kind of call here passing in the data and starting the process. return View(); } 

​

So, as the user is returned/routed to another view to continue working, this process keeps running independently.

​

Is this something that I can do with just threading? Or would I need to create some kind of other service or program that's completely separate just for this purpose?

What's the best way to have a long running process continue in the background on the server side independent from the user's interaction? Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team