Re: How to wait for thread?
- From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
- Date: Tue, 8 Aug 2006 17:10:11 -0700
"Brett Romero" <account@xxxxxxxxx> wrote in message
news:1155081229.482157.214280@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'd like the main thread to wait until these three threads have
completed their task:
LoadOjbects lo = new LoadOjbects();
lo.thrd1.Start();
lo.thrd2.Start();
lo.thrd3.Start();
while (lo.thrd1.IsAlive || lo.thrd2.IsAlive || lo.thrd3.IsAlive)
{
Thread.Sleep(500);
}
If you just want to wait for all three to end, without regard for the order
in which they end, you can just do:
lo.thrd1.Join();
lo.thrd2.Join();
lo.thrd2.Join();
// You won't get here until all 3 threads have completed
// ...but you can't tell which one completed first
// (nor does it matter).
-cd
.
- Follow-Ups:
- Re: How to wait for thread?
- From: Brett Romero
- Re: How to wait for thread?
- References:
- How to wait for thread?
- From: Brett Romero
- How to wait for thread?
- Prev by Date: How to wait for thread?
- Next by Date: how to hide tabpage header C# windows forms
- Previous by thread: How to wait for thread?
- Next by thread: Re: How to wait for thread?
- Index(es):
Relevant Pages
|
Loading