Threading in Delphi for .NET
(Page 1 of 15 )
See these building blocks for writing applications that respond to user input during process-intensive tasks. Rick Ross of PILLAR Technology Group covers processes, threading, AppDomain, user interface issues and more. (From
Delphi for .NET Developer's Guide by Xavier Pacheco, Sams, ISBN: 0-672-32443-1, 2004).

Applications that appear to be nonresponsive are seen as being poorly written. Whether it is waiting for a long-running report to finish, or printing a 100-page document, applications must respond to user input. Fortunately, writing responsive applications is not a difficult task as long as certain principles are understood.
This chapter provides the building blocks for writing applications that respond to user input during process-intensive tasks. In addition, these same concepts are applicable to other applications such as NT Services, Application Servers, and Internet applications.
Processes
A process is created when an application is started. This process contains an instruction pointer that keeps track of the location currently being executed. In addition to executable code, a process contains virtual address space, memory space, and numerous CPU registers.
The virtual address space contains a logical set of valid addresses in a process. Memory space contains the global process data—the stack where local variables are stored, the heap where memory is dynamically allocated, and the set of pages used for mapping virtual addresses to physical memory.
Processes have three unique states: running, stopped, or blocked. Stopped processes are those that are being debugged while blocked processes are waiting for the operating system to execute them. Each process is treated as an isolated entity that is scheduled by the operating system.
Because the operating system prevents processes from directly affecting each other, communication between two or more processes needs a predetermined protocol. Collectively, protocols used to communicate between multiple processes are called Interprocess Communications (IPC). Figure 14.1 illustrates multiple processes communicating with each other.

Figure 14.1 - Multiple processes communicating.
The Windows (NT and above) operating system has several IPC mechanisms to choose from. These include
Named Pipes
Shared Memory
Mutexes
Events
Semaphores
TCP/IP Sockets
Heavyweight is a term associated with processes because they are resource intensive. Starting and stopping a process is relatively slower than other alternatives, which are discussed in the next section. Despite the hunger for increased resources, the level of protection offered by the operating system for processes is unmatched.
This chapter is from Delphi for .NET Developer's Guide, by Xavier Pacheco (Sams, 2004, ISBN: 0-672-32443-1). Check it out at your favorite bookstore today.
Buy this book now. |
Next: Threading >>
More .NET Articles
More By Xavier Pacheco