C# : Not showing all processes in list

I've created a small app to show top 10 processes by working set size.
My problem is that it does not show the correct top 10 list.
The attached code is what I wrote. When I compare my list with task manager process list, the result are not the same.
In the task manager I see processes not listed in my list. for example the 'dwm' process is missing from my list.
but when I use :
Process[] processList = Process.GetProcessesByName("dwm");
the process is shown in the list

string[] TopTenName = new string[10];
        long[] TopTenVal = new long[10];

        private void Form1_Load(object sender, EventArgs e)
        {
            Process[] processList = Process.GetProcesses();

            string _Break;
            int _TopTenCount;
            foreach (Process p in processList)
            {
                _Break = "No";
                _TopTenCount = 0;
                while (_Break == "No")
                {
                    if (TopTenVal[_TopTenCount] < (p.WorkingSet64 / 1024))
                    {
                        TopTenName[_TopTenCount] = p.ProcessName;
                        TopTenVal[_TopTenCount] = p.WorkingSet64 / 1024;
                        _Break = "Yes";
                    }
                    _TopTenCount++;
                    if (_TopTenCount == 10) _Break = "Yes";
                }
            }

            ListViewItem lvName;
            ListViewItem lvVal;

            listView1.Items.Clear();
            listView1.BeginUpdate();

            for (int n = 0; n < 10; n++)
            {
                lvName = new ListViewItem();
                lvVal = new ListViewItem();

                lvName.Text = TopTenName[n];
                lvVal.Text = TopTenVal[n].ToString("0,0");

                lvName.SubItems.Add(lvVal.Text);
                listView1.Items.Add(lvName);
            }

            listView1.EndUpdate();
            listView1.View = View.Details;
            listView1.Focus();
        }

Open in new window

LVL 3
OrenRozenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Use the overloaded version of GetProcesses as below. I can't find the question I saw this on before, but there is a reason you have to do it this way and I cannot remember what it was :\
Process[] processList = Process.GetProcesses(Environment.MachineName);

Open in new window

0
käµfm³d 👽Commented:
I believe this also works:
Process[] processList = Process.GetProcesses(".");

Open in new window

0
OrenRozenAuthor Commented:
both suggestions didn't solve the issue.
another thing I didn't mention is that I'm running in 64 bit environment. don't no why it should matter, but...

0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

käµfm³d 👽Commented:
Maybe I'm confusing that with something else then :\

Are you compiling the code as x86 or x64?
0
OrenRozenAuthor Commented:
same results for x86 and x64. default is Any CPU.

what puzzles me is why the code (when using GetProcesses()) is not showing the 'dwm' process in the list while when using GetProcessesByName("dwm")
is (and the only) showing in the list.
BTW, the 'dwm' process is the third in memory size.
0
OrenRozenAuthor Commented:
no more ideas?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.