Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Performance / February 2004

Tip: Looking for answers? Try searching our database.

How to synchronize thread?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
KPH - 19 Feb 2004 09:41 GMT
Hi

I'm developing multi-thread program. My program always run the threads until client close the program. But a problem is thread function stop during my program is running cause there is some exception. I have timer that always checking all thread state of each threads, if they are stopped,  my program will retry to start that stopped thread again.

Would you please help me answer my question
1. Is there another way to check thread state
2. What is the cause of thread stop
3. Is there any way to automatic checking thread state by .NET features

Thanks
KP
Martin Maat - 19 Feb 2004 10:55 GMT
> 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.