Linq to Object: Play with OS Component

Linq to Object: Play with OS Component

  • Comments 1

 

Linq not only allows us to work with .NET objects but also gives us the power to play with OS components like EventLog, Registry, Processes etc. If you plan to develop tool which will monitor the system process activities and will notify admin if there is any unpredictable things happening. It is all about writing your own admin tool.

You need to have using System.Diagnostics on top of your page.

 

In Orcas Beta 1 code looks like,

 

var ProcessQuery = from p in Process.GetProcesses()

                   orderby p.PagedMemorySize64 descending

                   select new {

Name = p.ProcessName,

Size = p.PagedMemorySize64

};

 

foreach (var aa in ProcessQuery)

{

    Console.WriteLine(" [ " + aa.Size + " ] " + aa.Name);

}

 

I love LINQ. It is ……….

 

And the output is….

 

 [ 62271488 ] devenv

 [ 40300544 ] sqlservr

 [ 39219200 ] svchost

 [ 28323840 ] CSharp3_23Apr.vshost

 [ 16941056 ] CcmExec

 [ 16150528 ] InoTask

 [ 15310848 ] winlogon

 [ 15220736 ] InoRT

 [ 9261056 ] explorer

 [ 8540160 ] lsass

 [ 6107136 ] inetinfo

 [ 4919296 ] InoRpc

 [ 4702208 ] services

 [ 4599808 ] spoolsv

 [ 4210688 ] wmiprvse

 [ 3592192 ] svchost

 [ 3072000 ] svchost

 [ 3031040 ] winlogon

 [ 2322432 ] svchost

 [ 2064384 ] wmiprvse

 [ 1810432 ] csrss

 [ 1572864 ] GrooveMonitor

 [ 1568768 ] svchost

 [ 1531904 ] wdfmgr

 [ 1486848 ] rdpclip

 [ 1441792 ] igfxtray

 [ 1355776 ] alg

 [ 1142784 ] FwcAgent

 [ 1081344 ] FwcMgmt

 [ 942080 ] sqlbrowser

 [ 933888 ] sqlwriter

 [ 929792 ] ctfmon

 [ 741376 ] csrss

 [ 385024 ] logon.scr

 [ 155648 ] smss

 [ 0 ] System

 [ 0 ] Idle

 

 

 

Namoskar!!!

Leave a Comment
  • Please add 4 and 6 and type the answer here:
  • Post