473,394 Members | 1,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How do I cancel a lengthy process on server side?

I have an ASP.NET form that may take a very long time to process a
particular request. If the user closes the browser window, the request will
continue to process until it completes. This is a problem when a user tries
to re-establish a new session. Since the previous request is still being
processed, the new request must now wait for it to complete. Is there
anyway to force old IIS processing thread sessions to terminate if they are
no longer active?

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
Nov 19 '05 #1
6 2077
You could take a look at the isClientConnected property to see if it helps.

http://msdn.microsoft.com/library/de...ectedTopic.asp

Its often useful to run this type of check in a serperate thread end
evaluate it alongside your executing long process, and work out a way to
cancel the process if the client becomes disconnected.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Ken Varn" <nospam> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
I have an ASP.NET form that may take a very long time to process a
particular request. If the user closes the browser window, the request
will
continue to process until it completes. This is a problem when a user
tries
to re-establish a new session. Since the previous request is still being
processed, the new request must now wait for it to complete. Is there
anyway to force old IIS processing thread sessions to terminate if they
are
no longer active?

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------

Nov 19 '05 #2
At the level where the processing is being performed, I do not have access
to the Page.Response object. This is being done in a generic C++ DLL that
is not ASP.NET aware. Is there any way that I can cancel an old processing
thread on the next new request that comes in or are there any other
solutions?

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:OG**************@TK2MSFTNGP14.phx.gbl...
You could take a look at the isClientConnected property to see if it helps.
http://msdn.microsoft.com/library/de...ectedTopic.asp
Its often useful to run this type of check in a serperate thread end
evaluate it alongside your executing long process, and work out a way to
cancel the process if the client becomes disconnected.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Ken Varn" <nospam> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
I have an ASP.NET form that may take a very long time to process a
particular request. If the user closes the browser window, the request
will
continue to process until it completes. This is a problem when a user
tries
to re-establish a new session. Since the previous request is still being processed, the new request must now wait for it to complete. Is there
anyway to force old IIS processing thread sessions to terminate if they
are
no longer active?

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------


Nov 19 '05 #3
Could you not just save a reference to the Thread object that is performing
the lengthly operation, and when you need to cancel the thread, could could
either signal the thread, but since you said it is interop, it might be best
to call Thread.Abort() on it.

Actually now that I think about it, I am not sure in the
ThreadAbortException will be sent through interop code.

Hmmm....

bill
"Ken Varn" <nospam> wrote in message
news:eH****************@TK2MSFTNGP10.phx.gbl...
At the level where the processing is being performed, I do not have access
to the Page.Response object. This is being done in a generic C++ DLL that
is not ASP.NET aware. Is there any way that I can cancel an old processing thread on the next new request that comes in or are there any other
solutions?

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:OG**************@TK2MSFTNGP14.phx.gbl...
You could take a look at the isClientConnected property to see if it

helps.

http://msdn.microsoft.com/library/de...ectedTopic.asp

Its often useful to run this type of check in a serperate thread end
evaluate it alongside your executing long process, and work out a way to
cancel the process if the client becomes disconnected.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Ken Varn" <nospam> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
I have an ASP.NET form that may take a very long time to process a
particular request. If the user closes the browser window, the request will
continue to process until it completes. This is a problem when a user
tries
to re-establish a new session. Since the previous request is still being processed, the new request must now wait for it to complete. Is there
anyway to force old IIS processing thread sessions to terminate if they are
no longer active?

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------



Nov 19 '05 #4
The C++ module is managed, so maybe what you are saying will work.

So let me get this straight on what you are suggestion. Store the
Thread.CurrentThread in a Session variable, then on re-entry call the Abort
method on the thread. I'll give that a shot. It sounds like it might work.
Are there any adverse ramifications to IIS if I do this? I wasn't sure if
there was some standard ASP.NET call that I should make to abort an IIS
thread.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Could you not just save a reference to the Thread object that is performing the lengthly operation, and when you need to cancel the thread, could could either signal the thread, but since you said it is interop, it might be best to call Thread.Abort() on it.

Actually now that I think about it, I am not sure in the
ThreadAbortException will be sent through interop code.

Hmmm....

bill
"Ken Varn" <nospam> wrote in message
news:eH****************@TK2MSFTNGP10.phx.gbl...
At the level where the processing is being performed, I do not have access
to the Page.Response object. This is being done in a generic C++ DLL that is not ASP.NET aware. Is there any way that I can cancel an old

processing
thread on the next new request that comes in or are there any other
solutions?

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:OG**************@TK2MSFTNGP14.phx.gbl...
You could take a look at the isClientConnected property to see if it

helps.

http://msdn.microsoft.com/library/de...ectedTopic.asp

Its often useful to run this type of check in a serperate thread end
evaluate it alongside your executing long process, and work out a way to cancel the process if the client becomes disconnected.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Ken Varn" <nospam> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
>I have an ASP.NET form that may take a very long time to process a
> particular request. If the user closes the browser window, the request > will
> continue to process until it completes. This is a problem when a user > tries
> to re-establish a new session. Since the previous request is still

being
> processed, the new request must now wait for it to complete. Is there > anyway to force old IIS processing thread sessions to terminate if they > are
> no longer active?
>
> --
> -----------------------------------
> Ken Varn
> Senior Software Engineer
> Diebold Inc.
>
> EmailID = varnk
> Domain = Diebold.com
> -----------------------------------
>
>



Nov 19 '05 #5
Are you doing the long running process in your request thread? There is a
request timeout that is defaulted to 90 seconds and the thread will be
aborted by the runtime.

There are no problems with IIS calling the thread abort on a request thread.
Infact, it will return the thread to the request thread pool faster than
just letting it complete.

A couple things to consider with placing the Thread in Session:
It will only work with Session State InProc.
If the user uses the ctrl-n option, all browser windows will have the same
Session.

bill

"Ken Varn" <nospam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
The C++ module is managed, so maybe what you are saying will work.

So let me get this straight on what you are suggestion. Store the
Thread.CurrentThread in a Session variable, then on re-entry call the Abort method on the thread. I'll give that a shot. It sounds like it might work. Are there any adverse ramifications to IIS if I do this? I wasn't sure if
there was some standard ASP.NET call that I should make to abort an IIS
thread.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Could you not just save a reference to the Thread object that is performing
the lengthly operation, and when you need to cancel the thread, could

could
either signal the thread, but since you said it is interop, it might be

best
to call Thread.Abort() on it.

Actually now that I think about it, I am not sure in the
ThreadAbortException will be sent through interop code.

Hmmm....

bill
"Ken Varn" <nospam> wrote in message
news:eH****************@TK2MSFTNGP10.phx.gbl...
At the level where the processing is being performed, I do not have access to the Page.Response object. This is being done in a generic C++ DLL that is not ASP.NET aware. Is there any way that I can cancel an old

processing
thread on the next new request that comes in or are there any other
solutions?

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:OG**************@TK2MSFTNGP14.phx.gbl...
> You could take a look at the isClientConnected property to see if it
helps.
>
>

http://msdn.microsoft.com/library/de...ectedTopic.asp
>
> Its often useful to run this type of check in a serperate thread end
> evaluate it alongside your executing long process, and work out a way to
> cancel the process if the client becomes disconnected.
>
> --
> Regards
>
> John Timney
> ASP.NET MVP
> Microsoft Regional Director
>
> "Ken Varn" <nospam> wrote in message
> news:Ot**************@TK2MSFTNGP12.phx.gbl...
> >I have an ASP.NET form that may take a very long time to process a
> > particular request. If the user closes the browser window, the

request
> > will
> > continue to process until it completes. This is a problem when a user > > tries
> > to re-establish a new session. Since the previous request is
still being
> > processed, the new request must now wait for it to complete. Is

there > > anyway to force old IIS processing thread sessions to terminate if

they
> > are
> > no longer active?
> >
> > --
> > -----------------------------------
> > Ken Varn
> > Senior Software Engineer
> > Diebold Inc.
> >
> > EmailID = varnk
> > Domain = Diebold.com
> > -----------------------------------
> >
> >
>
>



Nov 19 '05 #6
Thanks for the info. I have increased the timeout in IIS to compensate for
the default delay.

I see your point on Session state. I should probably use Application state
instead.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Are you doing the long running process in your request thread? There is a
request timeout that is defaulted to 90 seconds and the thread will be
aborted by the runtime.

There are no problems with IIS calling the thread abort on a request thread. Infact, it will return the thread to the request thread pool faster than
just letting it complete.

A couple things to consider with placing the Thread in Session:
It will only work with Session State InProc.
If the user uses the ctrl-n option, all browser windows will have the same
Session.

bill

"Ken Varn" <nospam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
The C++ module is managed, so maybe what you are saying will work.

So let me get this straight on what you are suggestion. Store the
Thread.CurrentThread in a Session variable, then on re-entry call the

Abort
method on the thread. I'll give that a shot. It sounds like it might

work.
Are there any adverse ramifications to IIS if I do this? I wasn't sure if
there was some standard ASP.NET call that I should make to abort an IIS
thread.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Could you not just save a reference to the Thread object that is

performing
the lengthly operation, and when you need to cancel the thread, could

could
either signal the thread, but since you said it is interop, it might be
best
to call Thread.Abort() on it.

Actually now that I think about it, I am not sure in the
ThreadAbortException will be sent through interop code.

Hmmm....

bill
"Ken Varn" <nospam> wrote in message
news:eH****************@TK2MSFTNGP10.phx.gbl...
> At the level where the processing is being performed, I do not have

access
> to the Page.Response object. This is being done in a generic C++
DLL that
> is not ASP.NET aware. Is there any way that I can cancel an old
processing
> thread on the next new request that comes in or are there any other
> solutions?
>
> --
> -----------------------------------
> Ken Varn
> Senior Software Engineer
> Diebold Inc.
>
> EmailID = varnk
> Domain = Diebold.com
> -----------------------------------
> "John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
> news:OG**************@TK2MSFTNGP14.phx.gbl...
> > You could take a look at the isClientConnected property to see if
it > helps.
> >
> >
>

http://msdn.microsoft.com/library/de...ectedTopic.asp
> >
> > Its often useful to run this type of check in a serperate thread end > > evaluate it alongside your executing long process, and work out a way
to
> > cancel the process if the client becomes disconnected.
> >
> > --
> > Regards
> >
> > John Timney
> > ASP.NET MVP
> > Microsoft Regional Director
> >
> > "Ken Varn" <nospam> wrote in message
> > news:Ot**************@TK2MSFTNGP12.phx.gbl...
> > >I have an ASP.NET form that may take a very long time to process a > > > particular request. If the user closes the browser window, the
request
> > > will
> > > continue to process until it completes. This is a problem when a user
> > > tries
> > > to re-establish a new session. Since the previous request is

still > being
> > > processed, the new request must now wait for it to complete. Is

there
> > > anyway to force old IIS processing thread sessions to terminate

if they
> > > are
> > > no longer active?
> > >
> > > --
> > > -----------------------------------
> > > Ken Varn
> > > Senior Software Engineer
> > > Diebold Inc.
> > >
> > > EmailID = varnk
> > > Domain = Diebold.com
> > > -----------------------------------
> > >
> > >
> >
> >
>
>



Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Larry Woods | last post by:
I have a server page that has served an HTML page with a "Cancel" button on it, BUT this server page has not completed and is running a 15-30 second process before it completes. I want the browser...
3
by: dave | last post by:
Hi, Does anyone know how I could make an .exe launched server side from an aspx file run faster? When I use javascript client side it of couse is much faster. Here's my code This code does...
2
by: Stephen | last post by:
I have code which checks whether a datagrid is empty and if it is it shows a panel on my page. If its not empty then Im using the server.transfer to go to another page so as im able to use the...
5
by: atefshehata | last post by:
hi all, i'm using iis6 installed on win2003 , dotnet framework 1.1 . My problem is.. a page on my application have a lengthy process which takes about 4 minutes (performing database...
3
by: Stijn Vanroye | last post by:
Hi List, I'm running a query on a not-so-small db. Mostly this query runs fast enough, but every once in a while the query takes a long time to complete in wich case the users start banging away...
0
by: Stuart Whiteford | last post by:
Hi, I've got a basic web form, two textboxes, a couple of radio button groups, some required field validators, and a Submit and Cancel button. When the page loads, if I click the Cancel...
3
by: lakshmikandhan | last post by:
Hi All, Can anyone tell how to handle the Cancel button in the JavaScript Confirm() method?If we press cancel, I have to perform certain action in the Server side? Plz help me!! Thanx, Jacob.
13
by: michael sorens | last post by:
I have a lengthy sequence of operations that are executed and reported on in a status window in a Windows Form application. Some work is done by background threads but other work is not. I am...
2
by: tirath | last post by:
hi, I have a web site where user provide some search criteria and click on button "Search". I want to provide a "Cancel" button which user can click. In case search takes long, user clicks on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.