Search

Browse by Category
 
 
Hide Left Column
< Return to Safari Guides Main Page

Safari Guides

Topic: .NET

Using threads with VB.NET

Threads are the basic unit to which an operating system allocates processor time. The operating system allocates execution time to threads, not (as you might think) processes. A thread requires an owner process and cannot exist on its own. Processes, on the other hand, can contain multiple threads but must contain at least one thread--the main process thread (usually Sub Main). When the main process thread exits, the entire process is terminated--any other active threads will be prematurely terminated. Threads can share memory with other threads that are within the same process. A thread also has an associated set of resources that includes its own exception handlers, scheduling priority, and a set of structures that allow the operating system to preserve the thread's context as other threads are given execution time.

Cover GraphicTo learn about thread basics in VB.NET, read "An Overview of Basic Threading Concepts" Section in Chapter 3 of Designing Enterprise Applications with Microsoft Visual Basic .NET from Microsoft Press.

The simplest way to create a thread in VB.NET is to create a new instance of the Thread class. The Thread constructor takes a single argument: a delegate type. The CLR provides the ThreadStart delegate class specifically for this purpose, which points to a method you designate. This allows you to construct a thread and to say to it, "When you start, run this method."

Cover GraphicTo learn how to start, suspend and kill threads in VB.NET, read Section 20.1 of Programming Visual Basic .NET, 2nd Edition from O'Reilly Media.


Company | Terms of Service | Privacy Policy | Contact Us | Help | 508 Compliance
Copyright © 02-D Safari Books Online. All rights reserved.