473,378 Members | 1,699 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,378 software developers and data experts.

asp.net thread cleanup

gl
I currently have an asp.net web app that starts a thread in the global.asax
app start method. THe thread then runs for the duration of the app's life,
changing data in the background.

My question is what cleanup do i have to do for the thread when the app is
stopped? Do i need to do anything at all? Should I put a threadname.abort in
the application_end? I wasn't sure what cleanup to do.

Thanks.
Jan 23 '06 #1
2 2194
Your thread operates under some condition, right?
On each loop cycle this condition is begin checked, and if it is true thread
loop continues ( thread is going on )
and if not - loop is exited ( thread shutdowns ).

You can make this condition "visible" for the whole class that is you can
specify this condition in
application_end routine to false and thread will "naturally" exit.

About cleanup it depends what actions are performed in the thread, that is
if you use some unmanaged resources ( db connections, socket connections,
interop etc ) you have to either call Dispose or Close, or Shutdown. It
depends on the type of resources your thread is using.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"gl" <gl@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
I currently have an asp.net web app that starts a thread in the global.asax
app start method. THe thread then runs for the duration of the app's life,
changing data in the background.

My question is what cleanup do i have to do for the thread when the app is
stopped? Do i need to do anything at all? Should I put a threadname.abort
in
the application_end? I wasn't sure what cleanup to do.

Thanks.

Jan 23 '06 #2
gl
Thanks for the info. My thread is working exactly like you said. Is there
still anything that has to be done for the thread itself. Like calling
thread.abort in the loop (if it doesn't continue)? Thanks again for your help.

"Vadym Stetsyak" wrote:
Your thread operates under some condition, right?
On each loop cycle this condition is begin checked, and if it is true thread
loop continues ( thread is going on )
and if not - loop is exited ( thread shutdowns ).

You can make this condition "visible" for the whole class that is you can
specify this condition in
application_end routine to false and thread will "naturally" exit.

About cleanup it depends what actions are performed in the thread, that is
if you use some unmanaged resources ( db connections, socket connections,
interop etc ) you have to either call Dispose or Close, or Shutdown. It
depends on the type of resources your thread is using.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"gl" <gl@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
I currently have an asp.net web app that starts a thread in the global.asax
app start method. THe thread then runs for the duration of the app's life,
changing data in the background.

My question is what cleanup do i have to do for the thread when the app is
stopped? Do i need to do anything at all? Should I put a threadname.abort
in
the application_end? I wasn't sure what cleanup to do.

Thanks.


Jan 23 '06 #3

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

Similar topics

26
by: djw | last post by:
Hi, Folks- I have a question regarding the "proper" use of try: finally:... Consider some code like this: d = Device.open() try: d.someMethodThatCanRaiseError(...) if SomeCondition: raise...
7
by: mike | last post by:
Hi, I am having difficulty in creating a thread using pthread_create. It seems that pthread_create does not execute 'program', and returns -1; I have checked the API but I am not sure why this...
6
by: ll | last post by:
Hi, How to specify the timeout value(ms) for a thread? Thanks.
16
by: Alvin Bruney | last post by:
I'm observing that a sleeping thread changes to stopped after a while. Is that accepted framework behavior for web applications? My thread basically does some work, and sleeps for 60 minutes...
0
by: bob | last post by:
I have a somewhat complex question about how Threading works across the network. Below is the full source code of a program that will list any file modified on myServer. When I run this code from...
6
by: Brian Gideon | last post by:
How have you handled the finalization of thread-specific unmanaged resources? My question pertains specifically to using the DDEML which is a thread-specific API. In other words, every call to...
8
by: Rob | last post by:
Hello, I've got an issue where a process in a third party application has a dll which while exiting sort of freezes and runs away with processor cycles. i've written a block of code so that I...
1
by: Frank Millman | last post by:
Hi all I am doing something which works, but I have a gut feel that it cannot be relied upon. Can someone confirm this one way or the other. I have a multi-threaded server, which responds to...
4
by: Mathieu Prevot | last post by:
Hi, I have a threading.Thread class with a "for i in range(1,50)" loop within. When it runs and I do ^C, I have the error as many as loops. I would like to catch this exception (and if possible...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.