How to get task manager CPU and default memory column values

I need to return CPU and memory columns for each process in server from web
service like task manager shows by default.
I tried code below but s.TotalProcessorTime throws Win32exception with stack
below.
How to get CPU and real memory size from server using web service ?

Andrus.

        static void Processes(StringBuilder sb)
        {
            List<Process> processes = new List<Process>();
            foreach (Process process in Process.GetProcesses())
                processes.Add(process);

            processes.Sort((a, b) =>
            {
                return Math.Sign(b.PrivateMemorySize64 -
a.PrivateMemorySize64);
            });

            foreach (var s in processes)
            {
                sb.AppendLine(s.ProcessName + " CPU " +
s.TotalProcessorTime.ToString() + " " +
                                    " Memory " + s.PrivateMemorySize64/1024+
" kb");
            }
        }



System.ComponentModel.Win32Exception:
   at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32
access, Boolean throwIfExited)
   at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean
throwIfExited)
   at System.Diagnostics.Process.GetProcessTimes()
   at System.Diagnostics.Process.get_TotalProcessorTime()
....

0
Andrus
6/25/2010 12:37:34 PM
dotnet.languages.csharp 1931 articles. 0 followers. Follow

0 Replies
1184 Views

Similar Articles

[PageSpeed] 19

Reply:

Similar Artilces:

Find Next Row With No Value In It
I've got this nextrow = Cells.Find(what:="*", searchdirection:=xlPrevious, searchorder:=xlByRows).Row + 1 Cells(nextrow, 1).Select which will find nextrow with nothing in it and select cell in Col A, but now I've got formulas in the cells, so instead of finding the next row with nothing in it, I want to find the next row with no value - even if it's got a formula in it. Can I do this by amending what's in the what:="*" part of this code? It's always better to include all the parms for .find(). If you don't, then you're at ...

Need VB code to edit cell values
I need some VB to do the following please (My VB is not good enough yet) Starting from the active cell (call it the StartCell) In the cell to the left.. ThreeChars = Value.right(3) (the last three chars) Value = Value - last three characters (assume value is text & at least 3 chars present) In StartCell.. value = ThreeChars (as text, overwrite any contents of StartCell) move active cell one down from StartCell Examples of before/after -- Don Guillett Microsoft MVP Excel SalesAid Software dguillett@gmail.com "Stephen Ford" <Stephen_Ford_no@spam_uwclub....

WIll M2004 still get bug fixes?
Hello, Now that M2005 is out, will Microsoft still provide bug fixes to M2004 or are we forced to upgrade? Thanks Frank likely no additional fixes to M2004 .. but why upgrade because of that fact? Vernon "Frank" <farocco@hotmail.com> wrote in message news:utd$JCT9EHA.960@TK2MSFTNGP11.phx.gbl... > Hello, > > Now that M2005 is out, will Microsoft still provide bug fixes to M2004 or > are we forced to upgrade? > > > Thanks > Frank > > M05 has more bugs than M04 needs fixes. Likely it still will when M06 comes out. M04 will never get anot...

Export to Text Files Based on Field Value
I have an Access table with personal information (e.g., first name, last name, birth date, etc.) for thousands of people. The table is sorted by state. I want to be able to run a macro on that table that will create separate pipe delimited text files for each state with all fields included. Any help would be appreciated? -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/201005/1 Instead of exporting the table, export a query based on the table. You will have to have some code that loops through the states and modifies the quer...

WinDbg: Unable to get verifier list
I've been attempting to get to the bottom of a recurring BSOD crash happening on my system. I've already had 4 crashes so far over the past two weeks. So I've identified that NTOSKRNL.EXE is involved in all of them so far. It always somewhere in the stack. So I enabled Driver Verifier on NTOSKRNL, as well as HAL.DLL, NTFS.SYS, and FLTMGR.SYS which were also identified on the stack during various of the events. Okay so I had my latest crash yesterday, and it occurred on NTOSKRNL as well. The Verifier was already enabled on the system prior to this crash, and then wh...

Corrupted user profile.. how to get back to old name?
Running XP Pro at work. Login through a domain on Win2003SBS. I login with my name ssetnicky and password. We only use the server to store data really, it pushes out antivirus to all the machines, and we can access our accounting software's database which resides on the server. Each one of us has our own login and we're a member of the administrators group. My local computer's profile got corrupted around March 24th. When I logged on it looked as if I was viewing XP for the first time.. the little take a tour icon popped up, none of my quicklaunch icons were there, e...

change default settiings for spacing
I am trying to change the default setting for "Don't add space between paragraphs of the same style" by checking this box. It doesn't seem to work however. Is there something I need to do to change this default? Thanks This setting can be made only in style definitions, not in individual paragraphs or selected text or as a default for all styles. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "Lucid Moose" <Lucid Moose@discussions.microsoft.com> wrote in message news:55B13F51-D384...

My OL 2000 will not open-get error message
I have MS Office Premium-all of the other programs work. When I try to open OL2000 I get the the error msg. MS Outlook has encountered a problem and needs to close. I removed MS Office Premium and re-installed it-same problem. I also clicked repair from Control Panel-same problem. -- Roma Does it work correctly when trying to start Outlook in Safe Mode? Start-> Run; outlook.exe /safe For additional troubleshooting steps see; http://www.howto-outlook.com/faq/outlookdoesntstart.htm -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsoft Outlook 2003 http://www...

matrix and sorting with running value
I have a matrix which has 1 row grouping and 1 column grouping. The column is a date. The matrix has 1 field which is doing a running sum. I want the date column sorted in descedning order. I changed the sort of the column group and the dates do appear to sort in desc order. However the runningsum still appears to sort as if the date column is in asc order. ...

Default email server
Version: 2004 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: pop I am changing from cable broadband to ADSL2. Internet and email from my new address are working fine but I cannot get mail from my old address to forward through the new server. It appears that the old setting has a default to the old server that I cannot over ride. The sending mail setting in the old account has been changed to the new setting. Anything that I also need to do? Thanks in anticipation On 2010-03-03 00:54:42 -0500, Gary_Lawrence@officeformac.com said: > I cannot get mai...

Expand/Contract grouped columns in protected sheet
I�m trying to protect a sheet that has a pivottable with grouped columns. The problem is , after protecting the sheet , I can�t expand/contract the table. I get an error saying that I can�t use that command because it�s a protected sheet. Is there anyway around this? I.E. How can I protect a sheet, and still expand/contract a pivottable? --- Message posted from http://www.ExcelForum.com/ ...

how do you formula's but leave the value.
hi,how do you formula's but leave the value. if a1=1 and b1=2 and you have a code in c1 that says =a1+b1 c1 value would = 3 but how do you then delete the formula so that is stays as 3. i hope you understand what i mean. Hi Craig copy (don't cut) C1 and then click on C1 again and choose Edit / Paste Special now choose values and click Ok this should give you what you want Regards julie "craig" <anonymous@discussions.microsoft.com> wrote in message news:386401c4013b$71f004b0$a601280a@phx.gbl... > hi,how do you formula's but leave the value. > if a1=1 ...

Saving Attachments Default Setting
Whenever I save attachments to emails in Outlook Express it always defaults to My Documents File. This is very tiresome as this is not the file I want to use. Everytime I save attachements I have to browse for the correct file. I am sure it used to remember the file you last used and default to that but since I installed an update a couple of months ago it just goes back to My Documents. Help! ...

New task item for bunch of users to fill in a survey
Created a survey to be filled in by a bunch of users. How can I assign a task item for each of them with the least effort from my part, so they know to fill in the survey? I was thinking of filling a list with all the usernames, then start a workflow that creates the tasks having the "Assigned To" filled in by the list. Is this the right approach, or is there another/easier way I overlook? ~Hans ...

Change the Default Global Address List
Hello, I need to change the default global address list to show only users and contacts from my domain. Is it possible to change the default global address list? Nowadays, The default global address list shows users from my domain and many contacts from others domains. thanks in advance. i have the same situation. i'm trying to figure out how to make another global address list with enternal contacts. if you figure it out, i would love to hear about it:) "Maurit" wrote: > Hello, > > I need to change the default global address list to show only users and >...

Using VBA to find a value and select a range
I am trying to write a macro that will let me find a specific vale in a specific column, then select part of the row that the value is in, beginnign with a column 31 cells away from the column that the specific value is in. Someone suggested to me that I use an IF statement, but this is all I know about that: IF [value in column B] is “Grand Total” Then select from column AF to the end of the array in that row and copy it and paste a transpose of the values starting in cell I9 of worksheet X. What is the best way for me to accomplish this goal? Does this macro do what you...

To mark today's column with a special color or sign in work week view
In Microsoft Outlook, I use work week view, displaying me five columns, each for a single work day. I'd like to see today's column marked with a special color or sign. It there a way to do it? Thanks. Dan ...

Workbook default for borders
I have a number of workbooks which began their lives in Excel and the cell border setting is just fine. Nice dark lines, etc. Howver, I have other Excel files that were created from Lotus 1-2-3 files. The cell border settings in these files is not the same as the other files. The cell border line is gray. When I set a cell with a border and then click on Format, cell, border and then click on Choose the black color, the cell in question gets the desired format. But, no where can I find a way to set the default cell border this way for the whole workbook. Isn't there a menu op...

Default mailbox
Hello all - thanks for reading this. SBS 2000 > Exchange 2000 w/ all service packs, ect. Using POP3 connector, we retrieve messages from our ISP through one email account. I use sbs/exchange accounts to route all mail to users. This works fine, except if an email comes in for lisa@blah.com but is address to liza@blah.com (notice the "s" and "z") it goes to a queue and is mark unreachable. How can I get all messages that are not specifically addressed to users - or mistakes in the email address to go to a default email box - or to my administrator email box? T...

getting the output of a transform as DOM
Hello, I am doing an XSL transformation using the XslTransform object and I would like to get the output as a DOM (XmlDocument or XmlElement) Do I have to get it serialized and then parse it again, or is there anyway to do it more directly? TIA Andy Andy Fish wrote: > I am doing an XSL transformation using the XslTransform object and I would > like to get the output as a DOM (XmlDocument or XmlElement) > > Do I have to get it serialized and then parse it again, or is there anyway > to do it more directly? Sure there is direct way: XmlDocument res = new XmlDocument(); ...

Out of memory error when printing
Running Windows 98. Upgraded Office 2000 to Office XP. Fully patched OS and Office. Everything works fine except when trying to print from Outlook. Immediately generates a "Out of Memory or Resources ..." Any suggestions would be appreciated. Thanks, Bill ...

True or False if already in column
I have a list of unique phone numbers in column B. I want to enter a phone number in cell C2 with an if statement in cell D2 that states "Already in List" or "Not in List" Any suggestions? Thanks Tim Lookup() "Tim" <timh2ofall@comcast.net> wrote in message news:1129677983.692566.201670@g14g2000cwa.googlegroups.com... >I have a list of unique phone numbers in column B. I want to enter a > phone number in cell C2 with an if statement in cell D2 that states > "Already in List" or "Not in List" > Any suggestions? > Thanks...

columns are numbered????
My columns are numbered not lettered, Whats up with that? The rows are numbered as well. Dan, Tools/Options/General Uncheck R1C1 Reference style John "Dan Lindell" <dlind@xtreme.net> wrote in message news:402C4A58.4000708@xtreme.net... > My columns are numbered not lettered, Whats up with that? > The rows are numbered as well. > ...

RMS Store Operation Manager
Hello Everyone, I just finish to install on my laptop to test the RMS 1.3, it installed MSDE 2000 and I created the Database with RMS Store Administrator, but when I try to connect with the RMS Store Manager I get the following error: Not Found Error 201 : The Cashier was not found or the password is incorrect. Username: sa Password: sa DB: RMSSample Rommel J. Jimenez When logging into SO Manager or SO POS by default use the following: User Name: 1 Password: password Rob "Rommel J. Jimenez" <rommeljimenez@cantv.net> wrote in message news:O5RUeHADHHA.996@TK2MSFTNGP0...

set value in subform
I want to use the set value macro to set a control in a subform based on a control in another form. I have three forms: FormA, FormB, FormC. FormC is a subform within FormB. What I want is to be able to enter a value in FormA and then have FormC automatically updated. Currently, if I open FormA and FormC I am able to use the SetValue macro to do this. However, if I open FormA and FormB (recall that FormC is a subform within FormB) and try to run the macro, Access gives me an error. I'm assuming that it is because Access does not think FormC is open (even though it is op...