By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,360 Members | 3,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,360 IT Pros & Developers. It's quick & easy.

System.Threading.ThreadAbortException: Thread was being aborted.

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.