Make GetProcessInfo() for a single PID cheaper on Windows (dotnet/corefx#24198)
authordnickless <daniel.hegener@gmx.net>
Mon, 2 Oct 2017 16:47:54 +0000 (18:47 +0200)
committerJose Perez Rodriguez <joperezr@microsoft.com>
Mon, 2 Oct 2017 16:47:54 +0000 (09:47 -0700)
commita004fb52743d8ddf79f97b037f9a46cdd221b5d5
tree0157d2a61e251a31855966a750ff3c3410e290c5
parent69ae59d67dbedc96f2f43d9228b8fbc9a3ee94f7
Make GetProcessInfo() for a single PID cheaper on Windows (dotnet/corefx#24198)

* Improved performance of local process information retrieval by not constructing all ProcessInfo instances for all running processes anymore if only one is of interest.

* Removed superfluous space characters only

* Remove superfluous default parameter value

* Added a Debug.Assert()

* Moved a variable from the .Win32 file into the .Windows file in order to fix the UAP build and improved a Debug.Assert() message

* Attempt to make the UAP build happy again

* Removed the optionality of the "int processId" parameter from NtProcessInfoHelper.GetProcessInfos() to try and make the UAP build happy.

* Revert "Removed the optionality of the "int processId" parameter from NtProcessInfoHelper.GetProcessInfos() to try and make the UAP build happy."

This reverts commit dotnet/corefx@78ef4706f412d00d8396a073bd73f9fbd87a5696.

* Revert "Attempt to make the UAP build happy again"

This reverts commit dotnet/corefx@9ca6a02f2d2886ed9acc7e9643307e0ba0ca94b8.

* Fixed UAP builds by creating an NtProcessInfoHelper type with a contained GetProcessInfos(int processId = AllProcessIds) method in the ProcessManager.Uap.cs file which will just throw a NotSupportedException

* Aligned the implementations of GetProcessInfos(string machineName) for both Uap and Win32 into a shared Windows method (possible now because of previous check-in)

* Switched to a Predicate<T> based implementation instead of the "AllProcessIds = -1" magic number based version

Commit migrated from https://github.com/dotnet/corefx/commit/ebf11343ff80295d49607eef5114df917e45f9bb
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Uap.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs