Performance counter monitoring

I am using performance counters to monitor the CPU utilisation of server. The code in the Webmethod of my .asmx file as given below:

System.Diagnostics.PerformanceCounter PerformanceCounter1 =
new System.Diagnostics.PerformanceCounter();
float result;

PerformanceCounter1.CategoryName = "Processor";
PerformanceCounter1.CounterName = "% processor Time";
PerformanceCounter1.InstanceName = "_Total";
PerformanceCounter1.MachineName = ".";
System.Diagnostics.CounterSample sample1;
System.Diagnostics.CounterSample sample2;

// Retrieve a sample.
sample1 = PerformanceCounter1.NextSample();
// Wait some interval of time here and retrieve
// a second sample.
sample2 = PerformanceCounter1.NextSample();
// Pass both samples to the Calculate method.
result = System.Diagnostics.CounterSample.Calculate(sample1, sample2);

return result.ToString();
First time, the above method returns the CPU utilisation. However, next time the CPU utilisation shoots to maximum 100%. As a result of which my CPU gets hanged. In order to keep the process running I have to physically stop the ASPNET worker process (aspnet_wp.exe) using the Windows Task Manager utility.
Can anybody tell the solution, such that I am able to retrieve the CPU utilisation using performance counters without hanging the CPU.
P.S: the above code works fine in console application but not in WebService application
8/19/2003 10:12:20 PM 7071 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 40


Similar Artilces:

xml web service --uploading the file to the xml web service
how can we upload the file in the xml web service 1.i mean what will be the return value in the proxy class 2.and how am i going to send the file to the xml web service----regards Bipul Kumar Here are some links to articles that helped us get this done: Hope this helps....

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

Web service in .NET from Java Web Service
Hi there,I'm pretty new to .net (although i have years of experience with the old vb 6, access 2k, as well as java)... and need some with perhaps either some syntax or something.Here is the wsdl.<wsdl:definitions targetNamespace="">−<wsdl:types>−<schema targetNamespace="GetBookInfoByISBN">−<complexType name="BookInfoType">−<sequence><element maxOccurs="1" minOccurs="0" name="Title" nillable="true" type="xsd:string"/><element maxOccurs=&quo...

.NET web services Vs Java Web Services
Hello, does anyone know of a book or good source of information that compares .NET and Java Web Services? (I would like soemthing neutral if possible). I am thinking of approaching this subject for my dissertation? Many Thanks Rob Hi Rob, Last year I had to give a powepoint presentation on Web Services. I noticed some good books at barnes and noble that discussed the subject. These books were specific to Java and discussed Web Services in a very clear fashion. They gave some elementary examples that were easy to understand. I have not yet had the pleasure of creatin .NET Web Servi...

Can you return .net web controls in a .net page from a web service?
I've got a problem with a project. I've got to compile an entire .net page and return it as part of a Web Service for display. The problem I have is that I need to add WebControls and functionality to the page so that not only the html content and images are displayed (which I've managed) but that textboxes, labels, buttons and datasets can be displayed also. Essentially I need to make a call from one site for a page, populate the page and return it in a state as though it resided on the same server/webspace as the calling page. Code is currently built as follows into a string: strOpenHT...

Performance monitor and performance counters
I'm trying to figure out why performance counters won't work on my machine. We've got 2 windows 2003 servers, and if I try to access ANY of the performance counter related objects in the System.Diagnostic namespace I get this: Insufficient memory to continue the execution of the program. at System.Runtime.InteropServices.Marshal.AllocHGlobal(IntPtr cb) at System.Diagnostics.PerformanceMonitor.GetData(String item) Of course the call stack is actually larger than that, but the point is right here. The same code works fine on any of our XP or 2000 Pro boxes. Anyone know wha...

.Net Remoting vs Web services performance
Hi all,    I´m looking for info about performance in Remting and W.S.. I need updated info about how the performance is in the new version. I´ve found one but is for the asp 1.1, and i don´t think this will work for my proyect for info about this topic. Thanks all CarlosWhere is the Spanish Language in the user profile?...

Consuming .net xml web service in PHP
I have developed .net xml web service. I want a develope php client to access this web service. I dont have much knowledge about PHP. The web service i wrote accepts two string parameters FirstName and LastName, and returns string like Welcome (FisrstName)__(LastName) to web service. The sample php client code i am trying is as below: <?php require_once('nusoap.php'); $parameters = array ("FirstName"=>"Russel", "LastName"=>"Arnold"); // Create a new Soap object $soapclient = new soapclient('http://testwebservice/Servi... web service and xml problem
Hi all ,Im using ,net framework 2.0This is the web service I wrote by request of AS developer (Action script) but when he consume the service  he got the result like this .. <soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd="">   <soap:Body>     <GetTransportDetailsResponse xmlns="">       <GetTransportDetailsResult>&lt;TransportMethods&a...

any open source of xml .net web services?
any open source available for xml .net web services by using either or c#? please advise, thanks. I am not sure how to adapt framework. Basically I want to setup xml web services for people who is using colf fusion to connect my app. Also, what about sqlxml? you can host iis as soap calls too? which one is better sqlxml web service? or xml .net web services? please advise too. thanks for the help...

C#.NET Web services: Manipulating XML
Hi, I am developing a web service in C#.Net1.1 and a new bee to .NET. I have developed a web method to retrieve the data from database and I want to sent the response in the form of XML.I want to manipulate the dataset to get the desired XML.But I dont know how to do that? Can somebody help me in formatting the XML. Also, once I will format the XML, what return type I should use in web method to get XML file as output. Thanks in advance. First of all, I'm sure you already knnow that .NET 1.1 is rather old. At any rate, make sure you're using the latest service pack for .NET 1.1...

.NET vs Java XML Web Services
Does anyone know out of .NET and Java, which one performs better via XML web services? I think that it would really just depend on where you are wanting to deploy your web service. Since both have the overhead of a framwork behind them I would imagine that any performace gains would be small. If you are deploying in a Windows environment I would go with .NET, but mainly because I just like it better. If you want to deploy in Windows and Linux I would use Java. I am not sure how far Mono has come on the Linux platform and if you do not use C# mono would not help you anyway.It's not a bug, i...

creatig and returning xml in .net web service
I am new to the .net web service world. Recently I started writing a web service. This web service is going to interact with Java client. Hence I will be returning XML from web service. I am writing web service using in VS2008. My web service is goign to call a stored procedure. Stored procedure is supposed to retun me some records. Based on these records I have to create XML and return it as web service response. Till now I was able to write web service and stored proc. I am not sure how to build a response xml. Does anybody have any link or any idea on how to do this. I trie...

create valid xml to send to web service based on the schema provided by web service
Problem: I have a web page which is being populated from a dataset containing multiple tables.  I now need to call a web service and send the majority of this data to be incorporate into a mainframe system.  I have been supplied with the schema that the web service will be using to validate the data.  I am new to web services and I am not sure how to take my existing dataset and transform it into an xml document that matches the schema I was provided with. There is a main schema with an element which is a custom complex type.  This custom type consists of an element whi...

Best Practice for .Net Web Service access to a Web Service on a Test and Production Servers
Hello All, What is the best way to control a .Net web service to be able to access a remote server for testing and then point to another remote server to access the web service in production? Do I need to generate and maintain 2 different proxy objects? TIA, Bob Bob // first create the proxy if not isvalid( i_service) then i_service = create fundtraderproxy_TradeServicesClient_BasicHttpBinding_ITradeServices end if ///You'll see code something like this in the constructor of your proxy //dynamically set the endpoint url with the user supplied value - //r...

Web resources about - Performance counter monitoring -

Performance - Wikipedia, the free encyclopedia
A performance , in performing arts , generally comprises an event in which a performer or group of performers behave in a particular way for ...

Sapphire Readies Nitro R9 Fury: Custom Design and Enhanced Performance
... its own custom printed circuit board. Sapphire claims that the new Nitro R9 Fury will feature enhanced durability and slightly higher performance. ...

New DaaS platform aims to boost B2B marketing performance
Marketers are always keen to understand customer purchase intentions. But whilst there are many tools aimed at building consumer intelligence ...

China wearable device market continues to grow, with varied performance between segments, says IDC
According to the International Data Corporation (IDC ), wearable device shipments in China reached 7.37 million units in the third quarter of ...

Aleksandar Mitrovic - Anger fueled performance against Spurs - ESPN FC
Newcastle striker Aleksandar Mitrovic has revealed anger at not being selected in the team's starting XI fueled his decisive performance vs. ...

Justin Bieber Steals the Show With Flawless Performance of 'Sorry' on 'The Voice' Finale
In a finale filled with huge stars and massive hit songs, it was the 21-year-old singer who stole the spotlight.

Businesses Struggling with Application Performance Issues
Many IT teams still don't have a monitoring solution in place or don't have a solution equipped to detect certain types of performance issues. ...

Crytek’s stunning The Climb showcases VR performance on the Oculus Rift
Crytek has announced that its new VR title "The Climb" will showcase what the Oculus Rift can do. We step through the new game, and discuss just ...

Can Call of Duty: Black Ops III Outpace The Performance Of Previous Black Ops Titles?
It has been more than 5 weeks since the release of Activision Blizzard's Call of Duty: Black Ops III, and the sales trend for this title has ...

You Can Now Customize the Performance of Milwaukee Power Tools Through an App
Milwaukee isn’t the first power tool maker to connect its hardware to a smartphone app for automatic inventory tracking. But the company’s One-Key ...

Resources last updated: 12/19/2015 3:36:55 PM