C#

C#

Made by DeepSource

Consider using Environment.ProcessId instead of Process.GetCurrentProcess().Id CS-P1002

Performance
Critical

Using Process.GetCurrentProcess().Id requires that an instance of Process be allocated to access the required Id. It then adds additional overhead, i.e., disposing of the Process instance. It is therefore suggested that you use the reliable and performant alternative Environment.ProcessId.

Bad Practice

var pid = Process.GetCurrentProcess().Id;

Recommended

var pid = Environment.ProcessId;

Reference