> I'm developing multi-thread program. My program
> always run the threads until client close the program.
[quoted text clipped - 3 lines]
> each threads, if they are stopped, my program will
> retry to start that stopped thread again.
The better way would of course be to fix your thread code so that it won't
break any longer. Anyway you should put your thread code in a try catch
block so that exceptions won't make it terminate:
try
{
// your critical piece of thread code
}
catch (Exception e)
{
YourStaticLogFunction(e.Message);
// you wil want to know the date and time of the failure to spot any
regularity there
}
> 1. Is there another way to check thread state?
Your can maintain your watchdog approach as a second line of safety,
checking the IsAlive property. Don't forget to stop the timer before you
gracefully end the thread, you don't want to start the thread during an
intended shutdown :-).
> 2. What is the cause of thread stop?
Dunno, check the exception's message and you will see.
> 3. Is there any way to automatic checking thread state by .NET features?
Checking for failure is not your first goal. Control your code first using
exception handling, then if you're really paranoid, watch the thread every
now and then.
Martin.