469,900 Members | 1,583 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,900 developers. It's quick & easy.

Thread just stops running

I have noticed how the thread I created just stops running. I have added
several exceptions to the thread

System.Threading.SynchronizationLockException
System.Threading.ThreadAbortException
System.Threading.ThreadInterruptedException
System.Threading.ThreadStateException

to see if I could get more information about why the thread stops running
but that code is never executed. Any ideas on how I can debug this?

Thanks in advance.

Nov 19 '05 #1
9 2793
You need to provide more context than this if you want the problem to be
solved

--
Regards,
Alvin Bruney

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
------------------------------------------------------------

"mareal" <m@m.com> wrote in message
news:39**********************************@microsof t.com...
I have noticed how the thread I created just stops running. I have added
several exceptions to the thread

System.Threading.SynchronizationLockException
System.Threading.ThreadAbortException
System.Threading.ThreadInterruptedException
System.Threading.ThreadStateException

to see if I could get more information about why the thread stops running
but that code is never executed. Any ideas on how I can debug this?

Thanks in advance.

Nov 19 '05 #2
A thread stops running as soon as its parent thread stops running.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"mareal" <m@m.com> wrote in message
news:39**********************************@microsof t.com...
I have noticed how the thread I created just stops running. I have added
several exceptions to the thread

System.Threading.SynchronizationLockException
System.Threading.ThreadAbortException
System.Threading.ThreadInterruptedException
System.Threading.ThreadStateException

to see if I could get more information about why the thread stops running
but that code is never executed. Any ideas on how I can debug this?

Thanks in advance.

Nov 19 '05 #3
Thanks Kevin. The parent thread (as I understand it) is the aspnet_wp process
and as far I can tell, it is still running. The reason why I am saying this
is because I can access other ASP.NET applications on the same server. I have
also checked the event log and I don't aspnet_wp being recycled. What am I
missing?

"Kevin Spencer" wrote:
A thread stops running as soon as its parent thread stops running.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"mareal" <m@m.com> wrote in message
news:39**********************************@microsof t.com...
I have noticed how the thread I created just stops running. I have added
several exceptions to the thread

System.Threading.SynchronizationLockException
System.Threading.ThreadAbortException
System.Threading.ThreadInterruptedException
System.Threading.ThreadStateException

to see if I could get more information about why the thread stops running
but that code is never executed. Any ideas on how I can debug this?

Thanks in advance.


Nov 19 '05 #4
what is the looping structure in your thread? are you sure you are catching
all errors? what is its normal exit trigger?

if you code it correctly a thread will run the life of the appdomain its
created in.

-- bruce (sqlwork.com)

"mareal" <m@m.com> wrote in message
news:E8**********************************@microsof t.com...
| Thanks Kevin. The parent thread (as I understand it) is the aspnet_wp
process
| and as far I can tell, it is still running. The reason why I am saying
this
| is because I can access other ASP.NET applications on the same server. I
have
| also checked the event log and I don't aspnet_wp being recycled. What am I
| missing?
|
| "Kevin Spencer" wrote:
|
| > A thread stops running as soon as its parent thread stops running.
| >
| > --
| > HTH,
| >
| > Kevin Spencer
| > Microsoft MVP
| > ..Net Developer
| > What You Seek Is What You Get.
| >
| > "mareal" <m@m.com> wrote in message
| > news:39**********************************@microsof t.com...
| > >I have noticed how the thread I created just stops running. I have
added
| > > several exceptions to the thread
| > >
| > > System.Threading.SynchronizationLockException
| > > System.Threading.ThreadAbortException
| > > System.Threading.ThreadInterruptedException
| > > System.Threading.ThreadStateException
| > >
| > > to see if I could get more information about why the thread stops
running
| > > but that code is never executed. Any ideas on how I can debug this?
| > >
| > > Thanks in advance.
| > >
| >
| >
| >
Nov 19 '05 #5
Hello Bruce. I am sure I am catching all errors:

System.Threading.SynchronizationLockException
System.Threading.ThreadAbortException
System.Threading.ThreadInterruptedException
System.Threading.ThreadStateException
System.Exception

The looping structure is a

While True
.... (local code)
.... Call another method
.... (+ local code)
End While

I have not added an exit trigger yet. I wanted to fix this problem first.
"bruce barker" wrote:
what is the looping structure in your thread? are you sure you are catching
all errors? what is its normal exit trigger?

if you code it correctly a thread will run the life of the appdomain its
created in.

-- bruce (sqlwork.com)

"mareal" <m@m.com> wrote in message
news:E8**********************************@microsof t.com...
| Thanks Kevin. The parent thread (as I understand it) is the aspnet_wp
process
| and as far I can tell, it is still running. The reason why I am saying
this
| is because I can access other ASP.NET applications on the same server. I
have
| also checked the event log and I don't aspnet_wp being recycled. What am I
| missing?
|
| "Kevin Spencer" wrote:
|
| > A thread stops running as soon as its parent thread stops running.
| >
| > --
| > HTH,
| >
| > Kevin Spencer
| > Microsoft MVP
| > ..Net Developer
| > What You Seek Is What You Get.
| >
| > "mareal" <m@m.com> wrote in message
| > news:39**********************************@microsof t.com...
| > >I have noticed how the thread I created just stops running. I have
added
| > > several exceptions to the thread
| > >
| > > System.Threading.SynchronizationLockException
| > > System.Threading.ThreadAbortException
| > > System.Threading.ThreadInterruptedException
| > > System.Threading.ThreadStateException
| > >
| > > to see if I could get more information about why the thread stops
running
| > > but that code is never executed. Any ideas on how I can debug this?
| > >
| > > Thanks in advance.
| > >
| >
| >
| >

Nov 19 '05 #6
then try

while true
try
... your thread code
catch
try
log error
catch
.. can't log
end try
end try
end while

note: your thread will be running with the asp.net worker process id, and
will have limited permissions.

-- bruce (sqlwork.com)

"mareal" <m@m.com> wrote in message
news:6D**********************************@microsof t.com...
| Hello Bruce. I am sure I am catching all errors:
|
| System.Threading.SynchronizationLockException
| System.Threading.ThreadAbortException
| System.Threading.ThreadInterruptedException
| System.Threading.ThreadStateException
| System.Exception
|
| The looping structure is a
|
| While True
| ... (local code)
| ... Call another method
| ... (+ local code)
| End While
|
| I have not added an exit trigger yet. I wanted to fix this problem first.
|
|
| "bruce barker" wrote:
|
| > what is the looping structure in your thread? are you sure you are
catching
| > all errors? what is its normal exit trigger?
| >
| > if you code it correctly a thread will run the life of the appdomain
its
| > created in.
| >
| > -- bruce (sqlwork.com)
| >
| >
| >
| >
| >
| > "mareal" <m@m.com> wrote in message
| > news:E8**********************************@microsof t.com...
| > | Thanks Kevin. The parent thread (as I understand it) is the aspnet_wp
| > process
| > | and as far I can tell, it is still running. The reason why I am saying
| > this
| > | is because I can access other ASP.NET applications on the same server.
I
| > have
| > | also checked the event log and I don't aspnet_wp being recycled. What
am I
| > | missing?
| > |
| > | "Kevin Spencer" wrote:
| > |
| > | > A thread stops running as soon as its parent thread stops running.
| > | >
| > | > --
| > | > HTH,
| > | >
| > | > Kevin Spencer
| > | > Microsoft MVP
| > | > ..Net Developer
| > | > What You Seek Is What You Get.
| > | >
| > | > "mareal" <m@m.com> wrote in message
| > | > news:39**********************************@microsof t.com...
| > | > >I have noticed how the thread I created just stops running. I have
| > added
| > | > > several exceptions to the thread
| > | > >
| > | > > System.Threading.SynchronizationLockException
| > | > > System.Threading.ThreadAbortException
| > | > > System.Threading.ThreadInterruptedException
| > | > > System.Threading.ThreadStateException
| > | > >
| > | > > to see if I could get more information about why the thread stops
| > running
| > | > > but that code is never executed. Any ideas on how I can debug
this?
| > | > >
| > | > > Thanks in advance.
| > | > >
| > | >
| > | >
| > | >
| >
| >
| >
Nov 19 '05 #7
Hello Bruce and thank you for your suggestion. I did what you told me and
unfortunately nothing changed. I can still see one thread (I only created
two) dying. Look at the log I am outputting:

The entry at the bottom represents me stopping the aspnet_wp.exe process.
Then you will thread 1 and 2. Around 8:37:04 is when thread 0 died...

DATE,TIME,EVENT CONTENT

3/9/2005,8:38:49 AM,Thread ID# 1;
3/9/2005,8:38:46 AM,Thread ID# 1;
3/9/2005,8:38:42 AM,Thread ID# 1;
3/9/2005,8:38:39 AM,Thread ID# 1;
3/9/2005,8:38:36 AM,Thread ID# 1;
3/9/2005,8:38:33 AM,Thread ID# 1;
3/9/2005,8:38:30 AM,Thread ID# 1;
3/9/2005,8:38:27 AM,Thread ID# 1;
3/9/2005,8:38:24 AM,Thread ID# 1;
3/9/2005,8:38:20 AM,Thread ID# 1;
3/9/2005,8:38:17 AM,Thread ID# 1;
3/9/2005,8:38:14 AM,Thread ID# 1;
3/9/2005,8:38:11 AM,Thread ID# 1;
3/9/2005,8:38:08 AM,Thread ID# 1;
3/9/2005,8:38:05 AM,Thread ID# 1;
3/9/2005,8:38:02 AM,Thread ID# 1;
3/9/2005,8:37:58 AM,Thread ID# 1;
3/9/2005,8:37:55 AM,Thread ID# 1;
3/9/2005,8:37:52 AM,Thread ID# 1;
3/9/2005,8:37:49 AM,Thread ID# 1;
3/9/2005,8:37:46 AM,Thread ID# 1;
3/9/2005,8:37:42 AM,Thread ID# 1;
3/9/2005,8:37:39 AM,Thread ID# 1;
3/9/2005,8:37:36 AM,Thread ID# 1;
3/9/2005,8:37:33 AM,Thread ID# 1;
3/9/2005,8:37:30 AM,Thread ID# 1;
3/9/2005,8:37:27 AM,Thread ID# 1;
3/9/2005,8:37:24 AM,Thread ID# 1;
3/9/2005,8:37:21 AM,Thread ID# 1;
3/9/2005,8:37:17 AM,Thread ID# 1;
3/9/2005,8:37:14 AM,Thread ID# 1;
3/9/2005,8:37:11 AM,Thread ID# 1;
3/9/2005,8:37:08 AM,Thread ID# 1;
3/9/2005,8:37:04 AM,Thread ID# 1;
3/9/2005,8:37:04 AM,Thread ID# 0;
3/9/2005,8:37:01 AM,Thread ID# 1;
3/9/2005,8:37:01 AM,Thread ID# 0;
3/9/2005,8:36:58 AM,Thread ID# 1;
3/9/2005,8:36:58 AM,Thread ID# 0;
3/9/2005,8:36:55 AM,Thread ID# 1;
3/9/2005,8:36:54 AM,Thread ID# 0;
3/9/2005,8:36:52 AM,Thread ID# 1;
3/9/2005,8:36:51 AM,Thread ID# 0;
3/9/2005,8:36:49 AM,Thread ID# 1;
3/9/2005,8:36:48 AM,Thread ID# 0;
3/9/2005,8:36:45 AM,Thread ID# 1;
3/9/2005,8:36:45 AM,Thread ID# 0;
3/9/2005,8:36:42 AM,Thread ID# 0;
3/9/2005,8:36:42 AM,Thread ID# 1;
3/9/2005,8:36:39 AM,Thread ID# 0;
3/9/2005,8:36:39 AM,Thread ID# 1;
3/9/2005,8:36:36 AM,Thread ID# 1;
3/9/2005,8:36:33 AM,Thread ID# 1;
3/9/2005,8:36:30 AM,Thread ID# 1;
3/9/2005,8:36:27 AM,Thread ID# 1;
3/9/2005,8:36:26 AM,Thread ID# 0;
3/9/2005,8:36:23 AM,Thread ID# 1;
3/9/2005,8:36:22 AM,Thread ID# 0;
3/9/2005,8:36:20 AM,Thread ID# 1;
3/9/2005,8:36:18 AM,Thread ID# 0;
3/9/2005,8:36:17 AM,Thread ID# 1;
3/9/2005,8:36:14 AM,Thread ID# 0;
3/9/2005,8:36:14 AM,Thread ID# 1;
3/9/2005,8:36:10 AM,Thread ID# 1;
3/9/2005,8:36:10 AM,Thread ID# 0;
3/9/2005,8:36:07 AM,Thread ID# 1;
3/9/2005,8:36:06 AM,Thread ID# 0;
3/9/2005,8:36:04 AM,Thread ID# 1;
3/9/2005,8:36:02 AM,Thread ID# 0;
3/9/2005,8:36:01 AM,Thread ID# 1;
3/9/2005,8:35:58 AM,Thread ID# 0;
3/9/2005,8:35:57 AM,Thread ID# 1;
3/9/2005,8:35:54 AM,Thread ID# 1;
3/9/2005,8:35:54 AM,Thread ID# 0;
3/9/2005,8:35:51 AM,Thread ID# 1;
3/9/2005,8:35:50 AM,Thread ID# 0;
3/9/2005,8:35:48 AM,Thread ID# 1;
3/9/2005,8:35:46 AM,Thread ID# 0;
3/9/2005,8:35:45 AM,Thread ID# 1;
3/9/2005,8:35:43 AM,Thread ID# 0;
3/9/2005,8:35:42 AM,Thread ID# 1;
3/9/2005,8:35:40 AM,Thread ID# 0;
3/9/2005,8:35:38 AM,Thread ID# 1;
3/9/2005,8:35:37 AM,Thread ID# 0;
3/9/2005,8:35:35 AM,Thread ID# 1;
3/9/2005,8:35:34 AM,Thread ID# 0;
3/9/2005,8:35:32 AM,Thread ID# 1;
3/9/2005,8:35:31 AM,Thread ID# 0;
3/9/2005,8:35:29 AM,Thread ID# 1;
3/9/2005,8:35:28 AM,Thread ID# 0;
3/9/2005,8:35:26 AM,Thread ID# 1;
3/9/2005,8:35:25 AM,Thread ID# 0;
3/9/2005,8:35:23 AM,Thread ID# 1;
3/9/2005,8:35:21 AM,Thread ID# 0;
3/9/2005,8:35:20 AM,Thread ID# 1;
3/9/2005,8:35:18 AM,Thread ID# 0;
3/9/2005,8:35:16 AM,Thread ID# 1;
3/9/2005,8:35:15 AM,Thread ID# 0;
3/9/2005,8:35:13 AM,Thread ID# 1;
3/9/2005,8:35:12 AM,Thread ID# 0;
3/9/2005,8:35:10 AM,Thread ID# 1;
3/9/2005,8:35:09 AM,Thread ID# 0;
3/9/2005,8:35:07 AM,Thread ID# 1;
3/9/2005,8:35:06 AM,Thread ID# 0;
3/9/2005,8:35:03 AM,Thread ID# 1;
3/9/2005,8:35:03 AM,Thread ID# 0;
3/9/2005,8:35:00 AM,Thread ID# 1;
3/9/2005,8:35:00 AM,Thread ID# 0;
3/9/2005,8:34:57 AM,Thread ID# 1;
3/9/2005,8:34:57 AM,Thread ID# 0;
3/9/2005,8:34:54 AM,Thread ID# 1;
3/9/2005,8:34:54 AM,Thread ID# 0;
3/9/2005,8:34:51 AM,Thread ID# 1;
3/9/2005,8:34:51 AM,Thread ID# 0;
3/9/2005,8:34:48 AM,Thread ID# 1;
3/9/2005,8:34:48 AM,Thread ID# 0;
3/9/2005,8:34:45 AM,Thread ID# 1;
3/9/2005,8:34:45 AM,Thread ID# 0;
3/9/2005,8:34:42 AM,Thread ID# 1;
3/9/2005,8:34:41 AM,Thread ID# 0;
3/9/2005,8:34:38 AM,Thread ID# 1;
3/9/2005,8:34:38 AM,Thread ID# 0;
3/9/2005,8:34:23 AM,ASP.NET 1.1.4322.0,Error,1000,N/A,aspnet_wp.exe (PID:
3796) stopped unexpectedly.
"bruce barker" wrote:
then try

while true
try
... your thread code
catch
try
log error
catch
.. can't log
end try
end try
end while

note: your thread will be running with the asp.net worker process id, and
will have limited permissions.

-- bruce (sqlwork.com)

"mareal" <m@m.com> wrote in message
news:6D**********************************@microsof t.com...
| Hello Bruce. I am sure I am catching all errors:
|
| System.Threading.SynchronizationLockException
| System.Threading.ThreadAbortException
| System.Threading.ThreadInterruptedException
| System.Threading.ThreadStateException
| System.Exception
|
| The looping structure is a
|
| While True
| ... (local code)
| ... Call another method
| ... (+ local code)
| End While
|
| I have not added an exit trigger yet. I wanted to fix this problem first.
|
|
| "bruce barker" wrote:
|
| > what is the looping structure in your thread? are you sure you are
catching
| > all errors? what is its normal exit trigger?
| >
| > if you code it correctly a thread will run the life of the appdomain
its
| > created in.
| >
| > -- bruce (sqlwork.com)
| >
| >
| >
| >
| >
| > "mareal" <m@m.com> wrote in message
| > news:E8**********************************@microsof t.com...
| > | Thanks Kevin. The parent thread (as I understand it) is the aspnet_wp
| > process
| > | and as far I can tell, it is still running. The reason why I am saying
| > this
| > | is because I can access other ASP.NET applications on the same server.
I
| > have
| > | also checked the event log and I don't aspnet_wp being recycled. What
am I
| > | missing?
| > |
| > | "Kevin Spencer" wrote:
| > |
| > | > A thread stops running as soon as its parent thread stops running.
| > | >
| > | > --
| > | > HTH,
| > | >
| > | > Kevin Spencer
| > | > Microsoft MVP
| > | > ..Net Developer
| > | > What You Seek Is What You Get.
| > | >
| > | > "mareal" <m@m.com> wrote in message
| > | > news:39**********************************@microsof t.com...
| > | > >I have noticed how the thread I created just stops running. I have
| > added
| > | > > several exceptions to the thread
| > | > >
| > | > > System.Threading.SynchronizationLockException
| > | > > System.Threading.ThreadAbortException
| > | > > System.Threading.ThreadInterruptedException
| > | > > System.Threading.ThreadStateException
| > | > >
| > | > > to see if I could get more information about why the thread stops
| > running
| > | > > but that code is never executed. Any ideas on how I can debug
this?
| > | > >
| > | > > Thanks in advance.
| > | > >
| > | >
| > | >
| > | >
| >
| >
| >

Nov 19 '05 #8
I found the problem. It was in the method being called by the thread. After
adding tons of logging and bunch of catches I found it. Here are the details:

One of my test cases was to simulate a server crash. During the crashing, if
there was any communication that was already started by the client, it could
not be finished. So the “waiting for data” routine went into an infinite loop.

I also learned that the following command:

sender.SetSocketOption(System.Net.Sockets.SocketOp tionLevel.Socket,
System.Net.Sockets.SocketOptionName.ReceiveTimeout , 10000)

does nothing if the server crashed right after the communication
(client/server) started. So I added a timer in the “waiting for data”
routine. When the time expires I exit the loop throwing an exception, which
gives control back to the thread.

Thank you Bruce, Kevin and Alvin.

"mareal" wrote:
Hello Bruce and thank you for your suggestion. I did what you told me and
unfortunately nothing changed. I can still see one thread (I only created
two) dying. Look at the log I am outputting:

The entry at the bottom represents me stopping the aspnet_wp.exe process.
Then you will thread 1 and 2. Around 8:37:04 is when thread 0 died...

DATE,TIME,EVENT CONTENT

3/9/2005,8:38:49 AM,Thread ID# 1;
3/9/2005,8:38:46 AM,Thread ID# 1;
3/9/2005,8:38:42 AM,Thread ID# 1;
3/9/2005,8:38:39 AM,Thread ID# 1;
3/9/2005,8:38:36 AM,Thread ID# 1;
3/9/2005,8:38:33 AM,Thread ID# 1;
3/9/2005,8:38:30 AM,Thread ID# 1;
3/9/2005,8:38:27 AM,Thread ID# 1;
3/9/2005,8:38:24 AM,Thread ID# 1;
3/9/2005,8:38:20 AM,Thread ID# 1;
3/9/2005,8:38:17 AM,Thread ID# 1;
3/9/2005,8:38:14 AM,Thread ID# 1;
3/9/2005,8:38:11 AM,Thread ID# 1;
3/9/2005,8:38:08 AM,Thread ID# 1;
3/9/2005,8:38:05 AM,Thread ID# 1;
3/9/2005,8:38:02 AM,Thread ID# 1;
3/9/2005,8:37:58 AM,Thread ID# 1;
3/9/2005,8:37:55 AM,Thread ID# 1;
3/9/2005,8:37:52 AM,Thread ID# 1;
3/9/2005,8:37:49 AM,Thread ID# 1;
3/9/2005,8:37:46 AM,Thread ID# 1;
3/9/2005,8:37:42 AM,Thread ID# 1;
3/9/2005,8:37:39 AM,Thread ID# 1;
3/9/2005,8:37:36 AM,Thread ID# 1;
3/9/2005,8:37:33 AM,Thread ID# 1;
3/9/2005,8:37:30 AM,Thread ID# 1;
3/9/2005,8:37:27 AM,Thread ID# 1;
3/9/2005,8:37:24 AM,Thread ID# 1;
3/9/2005,8:37:21 AM,Thread ID# 1;
3/9/2005,8:37:17 AM,Thread ID# 1;
3/9/2005,8:37:14 AM,Thread ID# 1;
3/9/2005,8:37:11 AM,Thread ID# 1;
3/9/2005,8:37:08 AM,Thread ID# 1;
3/9/2005,8:37:04 AM,Thread ID# 1;
3/9/2005,8:37:04 AM,Thread ID# 0;
3/9/2005,8:37:01 AM,Thread ID# 1;
3/9/2005,8:37:01 AM,Thread ID# 0;
3/9/2005,8:36:58 AM,Thread ID# 1;
3/9/2005,8:36:58 AM,Thread ID# 0;
3/9/2005,8:36:55 AM,Thread ID# 1;
3/9/2005,8:36:54 AM,Thread ID# 0;
3/9/2005,8:36:52 AM,Thread ID# 1;
3/9/2005,8:36:51 AM,Thread ID# 0;
3/9/2005,8:36:49 AM,Thread ID# 1;
3/9/2005,8:36:48 AM,Thread ID# 0;
3/9/2005,8:36:45 AM,Thread ID# 1;
3/9/2005,8:36:45 AM,Thread ID# 0;
3/9/2005,8:36:42 AM,Thread ID# 0;
3/9/2005,8:36:42 AM,Thread ID# 1;
3/9/2005,8:36:39 AM,Thread ID# 0;
3/9/2005,8:36:39 AM,Thread ID# 1;
3/9/2005,8:36:36 AM,Thread ID# 1;
3/9/2005,8:36:33 AM,Thread ID# 1;
3/9/2005,8:36:30 AM,Thread ID# 1;
3/9/2005,8:36:27 AM,Thread ID# 1;
3/9/2005,8:36:26 AM,Thread ID# 0;
3/9/2005,8:36:23 AM,Thread ID# 1;
3/9/2005,8:36:22 AM,Thread ID# 0;
3/9/2005,8:36:20 AM,Thread ID# 1;
3/9/2005,8:36:18 AM,Thread ID# 0;
3/9/2005,8:36:17 AM,Thread ID# 1;
3/9/2005,8:36:14 AM,Thread ID# 0;
3/9/2005,8:36:14 AM,Thread ID# 1;
3/9/2005,8:36:10 AM,Thread ID# 1;
3/9/2005,8:36:10 AM,Thread ID# 0;
3/9/2005,8:36:07 AM,Thread ID# 1;
3/9/2005,8:36:06 AM,Thread ID# 0;
3/9/2005,8:36:04 AM,Thread ID# 1;
3/9/2005,8:36:02 AM,Thread ID# 0;
3/9/2005,8:36:01 AM,Thread ID# 1;
3/9/2005,8:35:58 AM,Thread ID# 0;
3/9/2005,8:35:57 AM,Thread ID# 1;
3/9/2005,8:35:54 AM,Thread ID# 1;
3/9/2005,8:35:54 AM,Thread ID# 0;
3/9/2005,8:35:51 AM,Thread ID# 1;
3/9/2005,8:35:50 AM,Thread ID# 0;
3/9/2005,8:35:48 AM,Thread ID# 1;
3/9/2005,8:35:46 AM,Thread ID# 0;
3/9/2005,8:35:45 AM,Thread ID# 1;
3/9/2005,8:35:43 AM,Thread ID# 0;
3/9/2005,8:35:42 AM,Thread ID# 1;
3/9/2005,8:35:40 AM,Thread ID# 0;
3/9/2005,8:35:38 AM,Thread ID# 1;
3/9/2005,8:35:37 AM,Thread ID# 0;
3/9/2005,8:35:35 AM,Thread ID# 1;
3/9/2005,8:35:34 AM,Thread ID# 0;
3/9/2005,8:35:32 AM,Thread ID# 1;
3/9/2005,8:35:31 AM,Thread ID# 0;
3/9/2005,8:35:29 AM,Thread ID# 1;
3/9/2005,8:35:28 AM,Thread ID# 0;
3/9/2005,8:35:26 AM,Thread ID# 1;
3/9/2005,8:35:25 AM,Thread ID# 0;
3/9/2005,8:35:23 AM,Thread ID# 1;
3/9/2005,8:35:21 AM,Thread ID# 0;
3/9/2005,8:35:20 AM,Thread ID# 1;
3/9/2005,8:35:18 AM,Thread ID# 0;
3/9/2005,8:35:16 AM,Thread ID# 1;
3/9/2005,8:35:15 AM,Thread ID# 0;
3/9/2005,8:35:13 AM,Thread ID# 1;
3/9/2005,8:35:12 AM,Thread ID# 0;
3/9/2005,8:35:10 AM,Thread ID# 1;
3/9/2005,8:35:09 AM,Thread ID# 0;
3/9/2005,8:35:07 AM,Thread ID# 1;
3/9/2005,8:35:06 AM,Thread ID# 0;
3/9/2005,8:35:03 AM,Thread ID# 1;
3/9/2005,8:35:03 AM,Thread ID# 0;
3/9/2005,8:35:00 AM,Thread ID# 1;
3/9/2005,8:35:00 AM,Thread ID# 0;
3/9/2005,8:34:57 AM,Thread ID# 1;
3/9/2005,8:34:57 AM,Thread ID# 0;
3/9/2005,8:34:54 AM,Thread ID# 1;
3/9/2005,8:34:54 AM,Thread ID# 0;
3/9/2005,8:34:51 AM,Thread ID# 1;
3/9/2005,8:34:51 AM,Thread ID# 0;
3/9/2005,8:34:48 AM,Thread ID# 1;
3/9/2005,8:34:48 AM,Thread ID# 0;
3/9/2005,8:34:45 AM,Thread ID# 1;
3/9/2005,8:34:45 AM,Thread ID# 0;
3/9/2005,8:34:42 AM,Thread ID# 1;
3/9/2005,8:34:41 AM,Thread ID# 0;
3/9/2005,8:34:38 AM,Thread ID# 1;
3/9/2005,8:34:38 AM,Thread ID# 0;
3/9/2005,8:34:23 AM,ASP.NET 1.1.4322.0,Error,1000,N/A,aspnet_wp.exe (PID:
3796) stopped unexpectedly.
"bruce barker" wrote:
then try

while true
try
... your thread code
catch
try
log error
catch
.. can't log
end try
end try
end while

note: your thread will be running with the asp.net worker process id, and
will have limited permissions.

-- bruce (sqlwork.com)

"mareal" <m@m.com> wrote in message
news:6D**********************************@microsof t.com...
| Hello Bruce. I am sure I am catching all errors:
|
| System.Threading.SynchronizationLockException
| System.Threading.ThreadAbortException
| System.Threading.ThreadInterruptedException
| System.Threading.ThreadStateException
| System.Exception
|
| The looping structure is a
|
| While True
| ... (local code)
| ... Call another method
| ... (+ local code)
| End While
|
| I have not added an exit trigger yet. I wanted to fix this problem first.
|
|
| "bruce barker" wrote:
|
| > what is the looping structure in your thread? are you sure you are
catching
| > all errors? what is its normal exit trigger?
| >
| > if you code it correctly a thread will run the life of the appdomain
its
| > created in.
| >
| > -- bruce (sqlwork.com)
| >
| >
| >
| >
| >
| > "mareal" <m@m.com> wrote in message
| > news:E8**********************************@microsof t.com...
| > | Thanks Kevin. The parent thread (as I understand it) is the aspnet_wp
| > process
| > | and as far I can tell, it is still running. The reason why I am saying
| > this
| > | is because I can access other ASP.NET applications on the same server.
I
| > have
| > | also checked the event log and I don't aspnet_wp being recycled. What
am I
| > | missing?
| > |
| > | "Kevin Spencer" wrote:
| > |
| > | > A thread stops running as soon as its parent thread stops running.
| > | >
| > | > --
| > | > HTH,
| > | >
| > | > Kevin Spencer
| > | > Microsoft MVP
| > | > ..Net Developer
| > | > What You Seek Is What You Get.
| > | >
| > | > "mareal" <m@m.com> wrote in message
| > | > news:39**********************************@microsof t.com...
| > | > >I have noticed how the thread I created just stops running. I have
| > added
| > | > > several exceptions to the thread
| > | > >
| > | > > System.Threading.SynchronizationLockException
| > | > > System.Threading.ThreadAbortException
| > | > > System.Threading.ThreadInterruptedException
| > | > > System.Threading.ThreadStateException
| > | > >
| > | > > to see if I could get more information about why the thread stops
| > running
| > | > > but that code is never executed. Any ideas on how I can debug
this?
| > | > >
| > | > > Thanks in advance.
| > | > >
| > | >
| > | >
| > | >
| >
| >
| >

Nov 19 '05 #9
Nice debugging work!

--
Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"mareal" <m@m.com> wrote in message
news:07**********************************@microsof t.com...
I found the problem. It was in the method being called by the thread. After
adding tons of logging and bunch of catches I found it. Here are the
details:

One of my test cases was to simulate a server crash. During the crashing,
if
there was any communication that was already started by the client, it
could
not be finished. So the "waiting for data" routine went into an infinite
loop.

I also learned that the following command:

sender.SetSocketOption(System.Net.Sockets.SocketOp tionLevel.Socket,
System.Net.Sockets.SocketOptionName.ReceiveTimeout , 10000)

does nothing if the server crashed right after the communication
(client/server) started. So I added a timer in the "waiting for data"
routine. When the time expires I exit the loop throwing an exception,
which
gives control back to the thread.

Thank you Bruce, Kevin and Alvin.

"mareal" wrote:
Hello Bruce and thank you for your suggestion. I did what you told me and
unfortunately nothing changed. I can still see one thread (I only created
two) dying. Look at the log I am outputting:

The entry at the bottom represents me stopping the aspnet_wp.exe process.
Then you will thread 1 and 2. Around 8:37:04 is when thread 0 died...

DATE,TIME,EVENT CONTENT

3/9/2005,8:38:49 AM,Thread ID# 1;
3/9/2005,8:38:46 AM,Thread ID# 1;
3/9/2005,8:38:42 AM,Thread ID# 1;
3/9/2005,8:38:39 AM,Thread ID# 1;
3/9/2005,8:38:36 AM,Thread ID# 1;
3/9/2005,8:38:33 AM,Thread ID# 1;
3/9/2005,8:38:30 AM,Thread ID# 1;
3/9/2005,8:38:27 AM,Thread ID# 1;
3/9/2005,8:38:24 AM,Thread ID# 1;
3/9/2005,8:38:20 AM,Thread ID# 1;
3/9/2005,8:38:17 AM,Thread ID# 1;
3/9/2005,8:38:14 AM,Thread ID# 1;
3/9/2005,8:38:11 AM,Thread ID# 1;
3/9/2005,8:38:08 AM,Thread ID# 1;
3/9/2005,8:38:05 AM,Thread ID# 1;
3/9/2005,8:38:02 AM,Thread ID# 1;
3/9/2005,8:37:58 AM,Thread ID# 1;
3/9/2005,8:37:55 AM,Thread ID# 1;
3/9/2005,8:37:52 AM,Thread ID# 1;
3/9/2005,8:37:49 AM,Thread ID# 1;
3/9/2005,8:37:46 AM,Thread ID# 1;
3/9/2005,8:37:42 AM,Thread ID# 1;
3/9/2005,8:37:39 AM,Thread ID# 1;
3/9/2005,8:37:36 AM,Thread ID# 1;
3/9/2005,8:37:33 AM,Thread ID# 1;
3/9/2005,8:37:30 AM,Thread ID# 1;
3/9/2005,8:37:27 AM,Thread ID# 1;
3/9/2005,8:37:24 AM,Thread ID# 1;
3/9/2005,8:37:21 AM,Thread ID# 1;
3/9/2005,8:37:17 AM,Thread ID# 1;
3/9/2005,8:37:14 AM,Thread ID# 1;
3/9/2005,8:37:11 AM,Thread ID# 1;
3/9/2005,8:37:08 AM,Thread ID# 1;
3/9/2005,8:37:04 AM,Thread ID# 1;
3/9/2005,8:37:04 AM,Thread ID# 0;
3/9/2005,8:37:01 AM,Thread ID# 1;
3/9/2005,8:37:01 AM,Thread ID# 0;
3/9/2005,8:36:58 AM,Thread ID# 1;
3/9/2005,8:36:58 AM,Thread ID# 0;
3/9/2005,8:36:55 AM,Thread ID# 1;
3/9/2005,8:36:54 AM,Thread ID# 0;
3/9/2005,8:36:52 AM,Thread ID# 1;
3/9/2005,8:36:51 AM,Thread ID# 0;
3/9/2005,8:36:49 AM,Thread ID# 1;
3/9/2005,8:36:48 AM,Thread ID# 0;
3/9/2005,8:36:45 AM,Thread ID# 1;
3/9/2005,8:36:45 AM,Thread ID# 0;
3/9/2005,8:36:42 AM,Thread ID# 0;
3/9/2005,8:36:42 AM,Thread ID# 1;
3/9/2005,8:36:39 AM,Thread ID# 0;
3/9/2005,8:36:39 AM,Thread ID# 1;
3/9/2005,8:36:36 AM,Thread ID# 1;
3/9/2005,8:36:33 AM,Thread ID# 1;
3/9/2005,8:36:30 AM,Thread ID# 1;
3/9/2005,8:36:27 AM,Thread ID# 1;
3/9/2005,8:36:26 AM,Thread ID# 0;
3/9/2005,8:36:23 AM,Thread ID# 1;
3/9/2005,8:36:22 AM,Thread ID# 0;
3/9/2005,8:36:20 AM,Thread ID# 1;
3/9/2005,8:36:18 AM,Thread ID# 0;
3/9/2005,8:36:17 AM,Thread ID# 1;
3/9/2005,8:36:14 AM,Thread ID# 0;
3/9/2005,8:36:14 AM,Thread ID# 1;
3/9/2005,8:36:10 AM,Thread ID# 1;
3/9/2005,8:36:10 AM,Thread ID# 0;
3/9/2005,8:36:07 AM,Thread ID# 1;
3/9/2005,8:36:06 AM,Thread ID# 0;
3/9/2005,8:36:04 AM,Thread ID# 1;
3/9/2005,8:36:02 AM,Thread ID# 0;
3/9/2005,8:36:01 AM,Thread ID# 1;
3/9/2005,8:35:58 AM,Thread ID# 0;
3/9/2005,8:35:57 AM,Thread ID# 1;
3/9/2005,8:35:54 AM,Thread ID# 1;
3/9/2005,8:35:54 AM,Thread ID# 0;
3/9/2005,8:35:51 AM,Thread ID# 1;
3/9/2005,8:35:50 AM,Thread ID# 0;
3/9/2005,8:35:48 AM,Thread ID# 1;
3/9/2005,8:35:46 AM,Thread ID# 0;
3/9/2005,8:35:45 AM,Thread ID# 1;
3/9/2005,8:35:43 AM,Thread ID# 0;
3/9/2005,8:35:42 AM,Thread ID# 1;
3/9/2005,8:35:40 AM,Thread ID# 0;
3/9/2005,8:35:38 AM,Thread ID# 1;
3/9/2005,8:35:37 AM,Thread ID# 0;
3/9/2005,8:35:35 AM,Thread ID# 1;
3/9/2005,8:35:34 AM,Thread ID# 0;
3/9/2005,8:35:32 AM,Thread ID# 1;
3/9/2005,8:35:31 AM,Thread ID# 0;
3/9/2005,8:35:29 AM,Thread ID# 1;
3/9/2005,8:35:28 AM,Thread ID# 0;
3/9/2005,8:35:26 AM,Thread ID# 1;
3/9/2005,8:35:25 AM,Thread ID# 0;
3/9/2005,8:35:23 AM,Thread ID# 1;
3/9/2005,8:35:21 AM,Thread ID# 0;
3/9/2005,8:35:20 AM,Thread ID# 1;
3/9/2005,8:35:18 AM,Thread ID# 0;
3/9/2005,8:35:16 AM,Thread ID# 1;
3/9/2005,8:35:15 AM,Thread ID# 0;
3/9/2005,8:35:13 AM,Thread ID# 1;
3/9/2005,8:35:12 AM,Thread ID# 0;
3/9/2005,8:35:10 AM,Thread ID# 1;
3/9/2005,8:35:09 AM,Thread ID# 0;
3/9/2005,8:35:07 AM,Thread ID# 1;
3/9/2005,8:35:06 AM,Thread ID# 0;
3/9/2005,8:35:03 AM,Thread ID# 1;
3/9/2005,8:35:03 AM,Thread ID# 0;
3/9/2005,8:35:00 AM,Thread ID# 1;
3/9/2005,8:35:00 AM,Thread ID# 0;
3/9/2005,8:34:57 AM,Thread ID# 1;
3/9/2005,8:34:57 AM,Thread ID# 0;
3/9/2005,8:34:54 AM,Thread ID# 1;
3/9/2005,8:34:54 AM,Thread ID# 0;
3/9/2005,8:34:51 AM,Thread ID# 1;
3/9/2005,8:34:51 AM,Thread ID# 0;
3/9/2005,8:34:48 AM,Thread ID# 1;
3/9/2005,8:34:48 AM,Thread ID# 0;
3/9/2005,8:34:45 AM,Thread ID# 1;
3/9/2005,8:34:45 AM,Thread ID# 0;
3/9/2005,8:34:42 AM,Thread ID# 1;
3/9/2005,8:34:41 AM,Thread ID# 0;
3/9/2005,8:34:38 AM,Thread ID# 1;
3/9/2005,8:34:38 AM,Thread ID# 0;
3/9/2005,8:34:23 AM,ASP.NET 1.1.4322.0,Error,1000,N/A,aspnet_wp.exe
(PID:
3796) stopped unexpectedly.
"bruce barker" wrote:
> then try
>
> while true
> try
> ... your thread code
> catch
> try
> log error
> catch
> .. can't log
> end try
> end try
> end while
>
> note: your thread will be running with the asp.net worker process id,
> and
> will have limited permissions.
>
> -- bruce (sqlwork.com)
>
> "mareal" <m@m.com> wrote in message
> news:6D**********************************@microsof t.com...
> | Hello Bruce. I am sure I am catching all errors:
> |
> | System.Threading.SynchronizationLockException
> | System.Threading.ThreadAbortException
> | System.Threading.ThreadInterruptedException
> | System.Threading.ThreadStateException
> | System.Exception
> |
> | The looping structure is a
> |
> | While True
> | ... (local code)
> | ... Call another method
> | ... (+ local code)
> | End While
> |
> | I have not added an exit trigger yet. I wanted to fix this problem
> first.
> |
> |
> | "bruce barker" wrote:
> |
> | > what is the looping structure in your thread? are you sure you are
> catching
> | > all errors? what is its normal exit trigger?
> | >
> | > if you code it correctly a thread will run the life of the
> appdomain
> its
> | > created in.
> | >
> | > -- bruce (sqlwork.com)
> | >
> | >
> | >
> | >
> | >
> | > "mareal" <m@m.com> wrote in message
> | > news:E8**********************************@microsof t.com...
> | > | Thanks Kevin. The parent thread (as I understand it) is the
> aspnet_wp
> | > process
> | > | and as far I can tell, it is still running. The reason why I am
> saying
> | > this
> | > | is because I can access other ASP.NET applications on the same
> server.
> I
> | > have
> | > | also checked the event log and I don't aspnet_wp being recycled.
> What
> am I
> | > | missing?
> | > |
> | > | "Kevin Spencer" wrote:
> | > |
> | > | > A thread stops running as soon as its parent thread stops
> running.
> | > | >
> | > | > --
> | > | > HTH,
> | > | >
> | > | > Kevin Spencer
> | > | > Microsoft MVP
> | > | > ..Net Developer
> | > | > What You Seek Is What You Get.
> | > | >
> | > | > "mareal" <m@m.com> wrote in message
> | > | > news:39**********************************@microsof t.com...
> | > | > >I have noticed how the thread I created just stops running. I
> have
> | > added
> | > | > > several exceptions to the thread
> | > | > >
> | > | > > System.Threading.SynchronizationLockException
> | > | > > System.Threading.ThreadAbortException
> | > | > > System.Threading.ThreadInterruptedException
> | > | > > System.Threading.ThreadStateException
> | > | > >
> | > | > > to see if I could get more information about why the thread
> stops
> | > running
> | > | > > but that code is never executed. Any ideas on how I can debug
> this?
> | > | > >
> | > | > > Thanks in advance.
> | > | > >
> | > | >
> | > | >
> | > | >
> | >
> | >
> | >
>
>
>

Nov 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Matt Rapoport | last post: by
8 posts views Thread by Cider123 | last post: by
6 posts views Thread by Tomaz Koritnik | last post: by
11 posts views Thread by Philip Wagenaar | last post: by
5 posts views Thread by Alan T | last post: by
3 posts views Thread by Jonathan Shan | last post: by
4 posts views Thread by =?Utf-8?B?QW1yaXQgS29obGk=?= | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.