Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Threads and Events

Status
Not open for further replies.

stevenk140

Programmer
Nov 20, 2003
34
CA
Hello,

I am opening a ASP.NET page, starting a thread, and would like that thraed to continue running UNTIL the page is closed. How would I stop this thread upon closing the page?

Steven
 
I think that the best solution to this is to make an OnClose script that will call an aspx page wich would make all the necessary work.
Code:
<body onclose=&quot;window.open('close.aspx')&quot;>
And in close.aspx do your job and then use a javascript
<script>
self.close()
</script>

This should be more efficient then tracking the Session End event or timeout.
 
I can't help but think that starting a thread in the page-load is a bad idea. What happens if the user's browser dies?

There will be no chance to tell the thread to kill itself (normally done with an AutoResetEvent or a integer value protected by an Interlocked instance).

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top