Skip to Main Content
C# in a Nutshell, Second Edition
book

C# in a Nutshell, Second Edition

by Peter Drayton, Ben Albahari, Ted Neward
August 2003
Intermediate to advanced content levelIntermediate to advanced
928 pages
32h 1m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell, Second Edition

Name

Process

Synopsis

This class represents a system process. Use it to start, stop, and interact with a process. To launch a new process, create an instance of ProcessStartInfo, set its properties, and pass it to the single-argument form of the static Start( ) method. This offers a great deal of control over process creation. To launch a process without customizing its StartInfo, simply call the one-string or two-string argument form of the static Start( ) method. The first string argument is the name of the program, batch file, or document to start, and the optional second argument contains any command-line arguments. You can also explicitly create a new instance of Process, set its StartInfo property, and call the Start( ) method to start the process.

GetCurrentProcess( ) creates a Process instance that represents the current process. Enumerate all running processes on the system by using GetProcesses( ). Use GetProcessesByName( ) to get all processes for a given program. GetProcessById( ) retrieves a Process given its process ID.

Use CloseMainWindow( ) to shut down a process that has a user interface. You can terminate a process with Kill( ), but this forces an abnormal termination, which may result in data corruption. If you would like to raise an event when the process finishes executing, use Exited (EnableRaisingEvents must be set to true).

Most of the properties allow you to access general information about the running process. However, this information is populated at the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# in a Nutshell

C# in a Nutshell

Ben Albahari, Ted Neward, Peter Drayton
C# 7.0 in a Nutshell

C# 7.0 in a Nutshell

Joseph Albahari, Ben Albahari
C# Cookbook, 2nd Edition

C# Cookbook, 2nd Edition

Jay Hilyard, Stephen Teilhet
C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard

Publisher Resources

ISBN: 0596005261Catalog PageErrata