471,605 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,605 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 2089
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

26 posts views Thread by djw | last post: by
7 posts views Thread by mike | last post: by
6 posts views Thread by ll | last post: by
6 posts views Thread by Brian Gideon | last post: by
1 post views Thread by Frank Millman | last post: by
4 posts views Thread by Mathieu Prevot | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

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.