Skip to content

Process Structure

Mario Gutierrez edited this page Jan 7, 2017 · 1 revision

Processes

The System.Diagnostics namespace defines a number of types that allow you to programmatically interact with Windows processes and various diagnostic-related types. The System.Diagnostics.Process class defines several useful methods and fields for interacting with a Windows process. This is pretty neat, you can look up and control pretty much any process. Some things you can access with Process are things like its PID, Name, Threads, Modules (*.dll and *.exe), and more.

Each process has a primary thread which is created when entering Main().

AppDomains

A Windows Process does not directly run an executable, instead applications run within an application domain. Application domains are logical partitions for assemblies and executables that are independent from one-another. A process can host several application domains, though, usually only the default application domain is needed. The default domain is created automatically for a .NET executable. You can interact with application domains through the System.AppDomain class.

Object Contexts

Each application domain also contains logical containers called contexts. These provide a context for certain objects to run under.

  • The default context is context 0.
  • Context-agile objects do not demand special contextual treatment.
  • Context-bound objects need special contextual treatment.

Context-bound objects have two main requirements. The first is that they are marked with an attribute from a special class of .NET attributes called context attributes. These attributes derive from the ContextAttribute base class. The other requirement is that the object derives from ContextBoundObject. Otherwise, the CLR might move the objects outside of its required context.

Clone this wiki locally