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

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 22907
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
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
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
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
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
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
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
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
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
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
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.