Skip to Main Content
Microsoft® .NET Compact Framework Kick Start
book

Microsoft® .NET Compact Framework Kick Start

by Erik Rubin, Ronnie Yates
August 2003
Beginner to intermediate content levelBeginner to intermediate
600 pages
12h 57m
English
Sams
Content preview from Microsoft® .NET Compact Framework Kick Start

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft® .NET Compact Framework (Core Reference)

Microsoft® .NET Compact Framework (Core Reference)

Andy Wigley, Stephen Wheelwright, Robert Burbidge, Rory MacLoed, Mark Sutton
Professional C# 5.0 and .NET 4.5.1

Professional C# 5.0 and .NET 4.5.1

Christian Nagel, Jay Glynn, Morgan Skinner

Publisher Resources

ISBN: 0672325705Purchase book