Chapter 10: Processes, AppDomains,Contexts, and Threads
In this Chapter you drill deeper into the constitution of a .NET executable host and come to understand the relationship between Win32 processes, application domains, contexts, and threads.
IN THE PREVIOUS CHAPTER, you examined the steps taken by the CLR to resolve the location of an externally referenced assembly. Here, you drill deeper into the constitution of a .NET executable host and come to understand the relationship between Win32 processes, application domains, contexts, and threads. In a nutshell, application domains (or simply, AppDomains) are logical subdivisions within a given process, which host a set of related .NET assemblies. As you will see, an application domain is further subdivided into contextual boundaries, which are used to group together likeminded .NET objects. Using the notion of context, the CLR is able to ensure that objects with special needs are handled appropriately.
Once you have come to understand the relationship between processes, application domains, and contexts, the remainder of this chapter examines how the .NET platform allows you to manually spawn multiple threads of execution for use by your program within its application domain. Using the types within the System.Threading namespace, the task of creating additional threads of execution has become extremely simple (if not downright trivial). Of course, the complexity of multithreaded development is not in the creation of threads, but in ensuring that your code base is well equipped to handle concurrent access to shared resources. Given this, the chapter closes by examining various synchronization primitives that the .NET Framework provides (which you will see is somewhat richer than raw Win32 threading primitives).