O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Querying Process Information

The Process class is the central abstraction to deal with processes. A series of static methods enables you to obtain Process instances by name, process ID, or unfiltered. We used this capability earlier in this book when discussing LINQ because the process list is a nice nontrivial data source that speaks to the imagination of many readers (at least, I think so). The following code shows this, also emphasizing the availability of many properties on Process objects:

var memoryHogs = from p in Process.GetProcesses()                 where p.WorkingSet64 > 50 * 1024 * 1024 /* 50 MB */                 select p;foreach (var memoryHog in memoryHogs)    Console.WriteLine(memoryHog);

The WorkingSet64 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required