O'Reilly logo

Microsoft® .NET Compact Framework Kick Start by Ronnie Yates, Erik Rubin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Blocking until a Thread Finishes

The desktop version of the .NET Framework features a method called Thread.Join(). Given a thread called l_Thread, if another thread calls l_Thread.Join(), then the other thread blocks until l_Thread terminates. The .NET Compact Framework does not support Thread.Join().

One way to wait for another thread to die is to use a busy wait. For example, the thread method might update the Boolean class member m_Alive to false as it exits. Another thread can sit and wait for the first thread to finish by writing code that looks like this:

C#
// Wait for another thread to set m_Alive to false
while (m_Alive)
{
}


VB
' Wait for another thread to set m_Alive to false
while (m_Alive = True)
End While

This would be a very bad ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required