473,767 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2091
You could take a look at the isClientConnect ed 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******** ******@TK2MSFTN GP12.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*****@despam med.com> wrote in message
news:OG******** ******@TK2MSFTN GP14.phx.gbl...
You could take a look at the isClientConnect ed 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******** ******@TK2MSFTN GP12.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
ThreadAbortExce ption will be sent through interop code.

Hmmm....

bill
"Ken Varn" <nospam> wrote in message
news:eH******** ********@TK2MSF TNGP10.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*****@despam med.com> wrote in message
news:OG******** ******@TK2MSFTN GP14.phx.gbl...
You could take a look at the isClientConnect ed 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******** ******@TK2MSFTN GP12.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.CurrentT hread 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******** *******@TK2MSFT NGP10.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
ThreadAbortExce ption will be sent through interop code.

Hmmm....

bill
"Ken Varn" <nospam> wrote in message
news:eH******** ********@TK2MSF TNGP10.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*****@despam med.com> wrote in message
news:OG******** ******@TK2MSFTN GP14.phx.gbl...
You could take a look at the isClientConnect ed 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******** ******@TK2MSFTN GP12.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******** ********@tk2msf tngp13.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.CurrentT hread 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******** *******@TK2MSFT NGP10.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
ThreadAbortExce ption will be sent through interop code.

Hmmm....

bill
"Ken Varn" <nospam> wrote in message
news:eH******** ********@TK2MSF TNGP10.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*****@despam med.com> wrote in message
news:OG******** ******@TK2MSFTN GP14.phx.gbl...
> You could take a look at the isClientConnect ed 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******** ******@TK2MSFTN GP12.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******** ********@TK2MSF TNGP10.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******** ********@tk2msf tngp13.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.CurrentT hread 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******** *******@TK2MSFT NGP10.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
ThreadAbortExce ption will be sent through interop code.

Hmmm....

bill
"Ken Varn" <nospam> wrote in message
news:eH******** ********@TK2MSF TNGP10.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*****@despam med.com> wrote in message
> news:OG******** ******@TK2MSFTN GP14.phx.gbl...
> > You could take a look at the isClientConnect ed 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******** ******@TK2MSFTN GP12.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
3272
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 user to be able to terminate the page before the server process has finished. What I tried was an onClick event that issued a "location.href..." in hopes that this would load this referenced page, etc. but I have found that the browser waits...
3
5290
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 work but it's extremely slow. What am I missing? Process Updater = new Process();
2
5877
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 items in an array list. My problem is that I also have had to incorporate some Javascript to see whether the user is ok with moving forward. Everything is fine and works apart from when the user clicks cancel on the pop-up Internet Explorer window it...
5
1210
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 transactions ..) to completes. user click on the transaction button to start this lengthy process.
3
3395
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 on the keyboard :-). What we would like to do is cancel the query after a certain time-out (e.g.30 sec.) Is there some way to send a command to the postgres sever to stop running the query? We're using Postgres 7.3.4 and the latest ODBC...
0
1701
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 button, the server-side event fires as normal. However, if I click the Submit button (with no information entered) the client-side validators fire, but if I then decide to press the Cancel
3
2085
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
1767
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 wondering how to recognize if the user presses an Escape (or even just a Shift key if that is simpler) so I may then abort the remaining foreground operations. To recognize a shift key I tried: if ((Control.ModifierKeys & Keys.Shift) ==...
2
1715
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 Cancel and he remains on the same page without any result. basically i do not want web client to wait for result. he should get option to cancel. Please help me, this is urgent. Thanks
0
9571
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9405
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9841
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5280
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5424
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3930
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3533
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.