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. 9 2994
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.
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.
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.
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.
| > >
| >
| >
| >
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. | > > | > | > | >
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.
| > | > >
| > | >
| > | >
| > | >
| >
| >
| >
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. | > | > > | > | > | > | > | > | > | > | > | >
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. | > | > > | > | > | > | > | > | > | > | > | >
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. > | > | > > > | > | > > | > | > > | > | > > | > > | > > | > > > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Matt Rapoport |
last post by:
I'm running an NT service with a thread. The thread performs a
calculation every so often and appends the number to a text file.
Every so often the thread just stops - or so it seems. The text...
|
by: Cider123 |
last post by:
I ran into a situation where my Window Service had to process 100,000+
files, when I first noticed I needed to tweak various routines.
Everything runs fine, but here's what I ran into:
In the...
|
by: Phil |
last post by:
Hi,
I've a simple asp.net page with one button.
In the OnClick event, I want to create a thread that will perform a
long runninf task.
Here is a sample code
in the OnClick
Thread t = new...
|
by: Tomaz Koritnik |
last post by:
I have a class that runs one of it's method in another thread. I use Thread
object to do this and inside ThreadMethod I have an infinite loop:
While (true)
{
// do something
Thread.Sleep(100);...
|
by: Philip Wagenaar |
last post by:
Hello,
I am using a timer object in my Windows Forms Application. Does the code in
..elapsed event run in a diffrent thread? If the interval is set to 10
milliseconds and the time to execute the...
|
by: NOtcarvinSPAM |
last post by:
Obviously wrapping a critical section around access to some set of
shared state variables flushes any cached data, etc so that the threads
involved don't see a stale copy. What I was wondering is...
|
by: Alan T |
last post by:
I will do several things in my thread:
Copy a file to a location
Update database record
Read the file content
Write the content to a log file
If I call Thread.Abort(), it may be possible to...
|
by: Jonathan Shan |
last post by:
Hello,
I am trying to call a function every 5 seconds. My understanding of
time.sleep() is during the sleep time everything "stops". However, in
my application, there are background processes...
|
by: =?Utf-8?B?QW1yaXQgS29obGk=?= |
last post by:
Hello,
I have a button that starts up a Thread and runs it in the background.
While the Thread is running, all the Ajax controls, including the events
fired by the PageRequestManager, stop...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |