Reputation: 7525
I understand I can do a Process.Start
to execute a console app from a web application, but I'd like thoughts on how to design this project correctly.
Authenticated users can submit requests that require a console app to be executed that does some backend work (may or may not take a long time) and the results from the console app needs to be displayed to the user.
Does the Process.Start
execute the console app in the same thread as the asp.net process? If so, does this 'lock' the user's browser? Should I be doing this asynchronously? If so, how is this recommended? How do I get results back from the console app?
Also, will this approach be scalable for several 100s of users submitting requests?
Any more replies?
Upvotes: 1
Views: 465
Reputation: 3210
The common solution is to have a database table where background operation queue is stored. So, when the user submits a request, a new record is added to the queue table. Console application runs periodically (e.g. scheduled with Cron), checks the queue table in the database, executes the tasks in background and writes the results to the database.
Such an approach is very scalable and widely used.
Upvotes: 1
Reputation: 224904
Process.Start
is a non-blocking call. You can use the Process
object and handle its events and read from or write to its streams.
As for if it's scalable, you might need a lot of powerful servers. It depends on the actual process.
Upvotes: 1