473,503 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Threading.ThreadAbortException: Thread was being aborted.

Hi

I am develloping an asp.net 2.0 application. For some tasks (daily
notifications to users via email), we use background threads. I rather have
this task as background thread of the asp.net application and not as a
service as as the installation procedure of a service on the productive
system would cause a lot of administrative overhead.

The thread is started in the global.asax file on startup. Strangely, after
some time, the thread is being aborted with a ThreadAbortException,
(Message: Thread was being aborted) I do not see a logical reason for this.
Does asp.net or iis prevent prevent threads running in the background for a
long time? If yes, how can i change this? This is really crucial for the
task, that must be performed.

Thanks in advance for any help

Daniel




PS: code snippet on how the thread is started
public static void Application_Start(object sender, EventArgs e) {

notificationThread = new Thread(new ThreadStart(StartNotificationThread));

notificationThread.IsBackground = true;

notificationThread.Priority = ThreadPriority.Lowest;

notificationThread.Start();


Jan 8 '07 #1
2 22945
Daniel Knöpfel wrote:
Hi

I am develloping an asp.net 2.0 application. For some tasks (daily
notifications to users via email), we use background threads. I rather have
this task as background thread of the asp.net application and not as a
service as as the installation procedure of a service on the productive
system would cause a lot of administrative overhead.

The thread is started in the global.asax file on startup. Strangely, after
some time, the thread is being aborted with a ThreadAbortException,
(Message: Thread was being aborted) I do not see a logical reason for this.
Does asp.net or iis prevent prevent threads running in the background fora
long time? If yes, how can i change this? This is really crucial for the
task, that must be performed.
Is the worker process being recycled? This is a "normal" aspect of life
for an asp.net application, and one of the reasons normally stated for
using a service rather than asp.net threads for background tasks.
However, you've indicated that you don't want to go down that route, so
I'll save the rest of the speech.

I don't believe we've played with these settings on our server, so I
believe I'm looking at the defaults, that the worker process is
automatically recycled every 29 hours, and that the worker process will
be shut down after 20 minutes of inactivity. So unless you change these
settings, the process your thread is living in will be torn down during
quiet times on the server.

Damien

Jan 8 '07 #2
Hi Damien

Thanks for your answer. Yes the worker process is recycled. However, i
believe the thead is aborted before the thread is actually recycled.
Furthermore, in case of recycling the global.asax startup event would be
raised and the worker process would be running again, which would be ok the
way we had it implemented. What might has an influence is the fact that the
thread is a background thread (if application is shut down (e.g. iisreset)
the thread should stop as well and that the thread is put to sleep for a
long time.
I will also deeper look at the recycling issue.

Thanks for your help Damien

Greetings

Daniel
e.g: Code snippets:

Thread start:
notificationThread = new Thread(new ThreadStart(StartNotificationThread));
notificationThread.Name = uniqueThreadName;

notificationThread.IsBackground = true;

notificationThread.Priority = ThreadPriority.Lowest;

notificationThread.Start();
Thread put to sleep:

Thread.Sleep(800000); // wait a long time and then try again!!


"Damien" <Da*******************@hotmail.comwrote in message
news:11**********************@q40g2000cwq.googlegr oups.com...
Daniel Knöpfel wrote:
Hi

I am develloping an asp.net 2.0 application. For some tasks (daily
notifications to users via email), we use background threads. I rather
have
this task as background thread of the asp.net application and not as a
service as as the installation procedure of a service on the productive
system would cause a lot of administrative overhead.

The thread is started in the global.asax file on startup. Strangely, after
some time, the thread is being aborted with a ThreadAbortException,
(Message: Thread was being aborted) I do not see a logical reason for
this.
Does asp.net or iis prevent prevent threads running in the background for
a
long time? If yes, how can i change this? This is really crucial for the
task, that must be performed.
Is the worker process being recycled? This is a "normal" aspect of life
for an asp.net application, and one of the reasons normally stated for
using a service rather than asp.net threads for background tasks.
However, you've indicated that you don't want to go down that route, so
I'll save the rest of the speech.

I don't believe we've played with these settings on our server, so I
believe I'm looking at the defaults, that the worker process is
automatically recycled every 29 hours, and that the worker process will
be shut down after 20 minutes of inactivity. So unless you change these
settings, the process your thread is living in will be torn down during
quiet times on the server.

Damien
Jan 8 '07 #3

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

Similar topics

1
3048
by: Christopher D. Wiederspan | last post by:
I've got a WebServices application that uses Crystal Reports to produce and then export Invoices to PDF format. Without getting into too many details, it's just a big loop statement that goes out...
2
636
by: José Joye | last post by:
When I unload an appdomain I have created, I always get the following exeption: System.Threading.ThreadAbortException: Thread was being aborted. Before calling the Unload() method, I set to...
0
3172
by: Lee Simpson | last post by:
Interesting problem. We have narrowed it down to the exact cause, and would like an explanation of what's going on behind the scenes. Simple bit of code: OleDbConnection con = new...
0
1151
by: MichaelR | last post by:
I'm getting a curious result from a module using WinInet on the client and IIS 6.0/ASP.NET on the server. Can't really tell if it's a client or a server issue. The client module uses...
4
6046
by: hitendra15 | last post by:
Hi following is the code which sends file to the browser means user can download file, but the code generates error message Thread Being Aborted., will any one put their thoughts protected void...
1
2277
by: kowshikj | last post by:
In a ASP.NET 1.1 application, we get this exception at xmlDoc.Load() when loading an XmlDocument. This does not seem to happen every time though. The xml file itself is only 10 KB and we don't use...
1
3031
by: mwallis76 | last post by:
Upon clicking on a hyperlink generated in a ASP.NET GridView control, I am finding Firefox 1.5 to crash. However, when clicking on the same link, Internet Explorer 6.0 works just fine and is...
3
1491
by: jediknight | last post by:
Having recently been asked to look into some bugs in one of our old web systems, I keep getting an error message in some try...catch statements that I've put in. Error message is Thread was...
1
2019
by: JoeP | last post by:
Hi All, 1) I am using code like the below outside of the Try.. Catch... Endtry and getting this message Within the Immediate Window. An exception of type...
0
7204
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,...
0
7091
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...
0
7282
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,...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5018
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...
0
4680
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...
0
3171
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...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
391
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...

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.