A user on a forum recently asked me how to find the processes that were currently running. A quick look at MSDN led me to the Process
object. The Process provides access to local and remote processes and
enables you to start and stop local system processes. Here’s how to find
out the top five processes that are consuming memory.
C#

C#
var query = (from p in System.Diagnostics.Process.GetProcesses() orderby p.PrivateMemorySize64 descending select p) .Skip(0) .Take(5) .ToList(); foreach (var item in query) { System.Diagnostics.Debug.WriteLine(item.ProcessName); }VB.NET
Dim query = ( _ From p In System.Diagnostics.Process.GetProcesses() _ Order By p.PrivateMemorySize64 Descending _ Select p).Skip(0).Take(5).ToList() For Each item In query System.Diagnostics.Debug.WriteLine(item.ProcessName) Next itemThe code above produces the following results on my computer:
No comments:
Post a Comment