Groups | Blog | Home
all groups > asp.net > december 2005 >

asp.net : difficultly stopping execution with a cancel button


alexander.glass NO[at]SPAM gmail.com
12/24/2005 10:43:14 PM
I have a buffered page that runs some code and outputs to the user to
update the progress of a method that takes several minutes to run. I
have a big problem however. There is no way to stop the code from
running once it begins. If you place a button on the page with code
that will trigger the method to stop, the button click event will not
fire until the long method completes. As a result, I can not think of
a way to create a cancel button. Has anyone had this problem before
and have a solution? Any help is greatly appreciated.

Alex
Peter Rilling
12/24/2005 11:09:30 PM
You might try running your process in some other thread so that it does not
block ASP.NET. What you could then do is store a reference to the thread in
a session variable so that when you click the button and the handler is
invoked, you can then access the thread and stop it. I have never done this
so I don't know if it will work, but you can try it.

[quoted text, click to view]

alexander.glass NO[at]SPAM gmail.com
12/25/2005 12:39:17 AM
I tried using a delegate to run the procedure asynchronously but as
soon as the page_load event ends so does my thread. Is there some way
to keep the thread from aborting?
AddThis Social Bookmark Button