System.Diagnostics.Process.Id Property

Gets the unique identifier for the associated process.

Syntax

[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.Diagnostics.MonitoringDescription("Process identifier.")]
public int Id { get; }

Value

Documentation for this section has not yet been entered.

Remarks

The process Process.Id is not valid if the associated process is not running. Therefore, you should ensure that the process is running before attempting to retrieve the Process.Id property. Until the process terminates, the process identifier uniquely identifies the process throughout the system.

You can connect a process that is running on a local or remote computer to a new System.Diagnostics.Process instance by passing the process identifier to the Process.GetProcessById(int, string) method. Process.GetProcessById(int, string) is a static method that creates a new component and sets the Process.Id property for the new System.Diagnostics.Process instance automatically.

Process identifiers can be reused by the system. The Process.Id property value is unique only while the associated process is running. After the process has terminated, the system can reuse the Process.Id property value for an unrelated process.

Because the identifier is unique on the system, you can pass it to other threads as an alternative to passing a System.Diagnostics.Process instance. This action can save system resources yet guarantee that the process is correctly identified.

Requirements

Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0