Last post Sep 13, 2006 12:44 PM by Bravo_H
Aug 14, 2006 04:31 PM|jasonwu|LINK
Does anyone know how to terminate an exe spawned from asp.net using System.Diagnostics's ProcessStartInfo and Process?
I'm creating an application which allows a user to send emails to his entire customer base (which might be hundreds of thousands of customers). When he chooses to start the email blast, I'll get my asp.net page to spawn an exe
that will do the heavy duty sending and writing to the database. The asp.net page will then use AJAX to periodically poll the database to find out how many emails have been sent out.
The thing is, the user needs the capability to stop the email blast at any time (e.g. he discovers that he has accidentally sent it to the wrong group of members etc.). Therefore, I need the ability to stop the email blast,
and the best way would be to terminate the exe or issue some kind of command so that it will do some cleaning up and then terminate. I thought of writing something to an external text file, which the exe will read before sending every email and decide on whether
to proceed from there. Terminating the exe would be a simple case of getting asp.net to write a flag into the text file that indicates termination. However, I realise that it might not be a good idea as opening and closing a streamreader and reading a file
hundreds of thousands of times in a loop is not the most efficient thing to do.
Does anyone have any good ideas? I'm out of ideas...
Thanks in advance,
Aug 14, 2006 07:42 PM|DarrellNorton|LINK
Aug 14, 2006 10:58 PM|jasonwu|LINK
Thanks for the reply. My asp.net page will basically spawn the exe and not wait for it to finish executing. This is because the email blast could take half an hour or up to an hour for large recordsets. Therefore, I need to
be able to terminate the process in a separate asp.net thread (it might be a postback, hence it would be executing as a separate thread already right?). So the Process object that I've declared when the page is first executed will not longer be valid and I
would have lost the reference to the exe.
Sep 13, 2006 12:44 PM|Bravo_H|LINK