473,804 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.abor t in
the application_end ? I wasn't sure what cleanup to do.

Thanks.
Jan 23 '06 #1
2 2210
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******** *************** ***********@mic rosoft.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.abor t
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******** *************** ***********@mic rosoft.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.abor t
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
2525
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 Error # Error is subclass of Exception
7
7857
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 isn't working. #include <stdio.h> #include <pthread.h>
6
19432
by: ll | last post by:
Hi, How to specify the timeout value(ms) for a thread? Thanks.
16
2052
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 before calling itself recursively, which means it is supposed to run on the hour every hour. But it automatically stops after 2 hours. I only get 2 emails, 1 per hour and then nothing. When I examine the threadstate during run-time, it has changed...
0
1174
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 myWorkstation and search myServer using a network share (using a Thread set to priority.Lowest) does myWorkstation inform myServer that this is a low priority thread? Since myServer is a production server, I don't want my file monitoring...
6
1938
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 the API using the same handle must be made on the same thread as the one that obtained the handle. Obviously, there is a conflict with the GC and the finalizer thread in cases where the programmer forgets to call Dispose on a wrapper class.
8
12410
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 can drill down into the process, and get the offending Thread's ID (since the only ones that will have the issue have higher User processor Time). But, I can't figure out how to have my .Net app 'kill' or 'suspend' a Thread
1
5482
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 client logins and sets up a thread for each active session. A thread can stay active for a long time. I use a subclass of threading.Thread to handle the session, to which I
4
2377
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 do some cleanup like in C pthreads) so the program finishes cleanly. Where and how can I do this ? in __run__ ? __init__ ? a try/except stuff ? Thanks, Mathieu
0
9579
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
10571
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
10326
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
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...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5520
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
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.