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 / New Users / April 2006

Tip: Looking for answers? Try searching our database.

.NET thread communication

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
martin - 05 Apr 2006 13:08 GMT
Hi,

I have a parent thread that starts a child thread. After the child thread
has been started I want the parent thread to wait until the child thread has
reached to a specific point in it's work. What .NET primitive should I use
for this "waiting until another thread reaches a specific point" mechanism? I
don't want to use some ugly hack which will spin the CPU at 100% or such..

regards,
martin
AMercer - 05 Apr 2006 13:26 GMT
> I have a parent thread that starts a child thread. After the child thread
> has been started I want the parent thread to wait until the child thread has
> reached to a specific point in it's work. What .NET primitive should I use
> for this "waiting until another thread reaches a specific point" mechanism? I
> don't want to use some ugly hack which will spin the CPU at 100% or such..

I suggest a ManualResetEvent (mre).  Create it in the parent thread in
blocking state.  Launch the new thread and wait on the mre (call
mre.WaitOne).  Have the child thread signal the mre at whatever point you
want.

The only difficulty is that the mre needs to be accessible to both threads.  
I think in .net 2005 the parent can pass the mre to the child, but I'm not at
2005 yet, so I don't know.  If you are .net 2003 or earlier, you will have to
worry this problem.  The easy way out is a shared variable/module, and if
there are no broader multi-threading issues, that will work.
martin - 05 Apr 2006 15:02 GMT
> I suggest a ManualResetEvent (mre).  

This sounds like exactly what I needed. Thanks man.

regards,
martin
joey.powell@topscene.com - 05 Apr 2006 15:09 GMT
I did this once with delegates and AsyncCallBack/Result. Might be worth
looking into. I had no idea what I was doing at the time, but I got it
to work!

JP

> Hi,
>
[quoted text clipped - 6 lines]
> regards,
> 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.