Modern operating systems support multitasking and multithreading. Multitasking is the capability of the operating system to load many programs into memory simultaneously and share CPU time between the programs. In modern operating systems with memory protections , each task is set in its own virtual address space, which cannot be accessed by other tasks . This arrangement makes computers much more stable, but it also means that the cost of setting up a new, independent computing job as its own task is relatively expensive. Multithreading is the capability of the operating system to support many independent units of execution in a single process. Each unit of execution is a thread, and each thread receives slices of CPU time. However, each thread occupies the same virtual address space. So, it is possible for one thread to interfere destructively with data used by another thread. However, setting up a new thread is far less expensive than setting up a whole new task, because no new address space is needed. The .NET Compact Framework (CF) lets developers use the multithreading support available in the Windows CE operating system. However, there are some important limitations in Windows CE's support of multithreading that you should be aware of:
The .NET Compact Framework supports threads in two ways. The first is through a Thread object. Through the Thread object, developers can spawn, terminate, and pass messages between threads. The second way to simulate threading behavior is through the Timer , an object that is familiar to Visual Basic developers. We discuss both threads and timers in great detail in this chapter. |