NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Process.Id

Gets the unique identifier for the associated process.

[Visual Basic]
Public ReadOnly Property Id As Integer
[C#]
public int Id {get;}
[C++]
public: __property int get_Id();
[JScript]
public function get Id() : int;

Property Value

The system-generated unique identifier of the associated process referenced by the Process instance.

Exceptions

Exception Type Condition
SystemException No process Id has been set.

-or-

There is no process associated with this Process object.

Remarks

The process Id does not exist if the associated process is not running. Therefore, you should either ensure that the process is running before attempting to retrieve its Id, or handle the exception that would be thrown if the process has not been started. Until the process terminates, the process identifier uniquely identifies the process throughout the system.

You can use the ID of an associated process on a local or remote computer to connect a running process to a new Process component by using the GetProcessById method. GetProcessById is a static (in Visual Basic Shared) method that creates a new component and sets the Id property for the new Process automatically.

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

Because the Id is unique on the system, it can be passed to other threads, as an alternative to passing a Process component. This can save system resources yet guarantees that the process is being correctly identified.

See Also

Process Class | Process Members | System.Diagnostics Namespace | Handle | GetProcessById