Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6054251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:07:55+00:00 2026-05-23T08:07:55+00:00

I have a method in a web service I am writing that compiles a

  • 0

I have a method in a web service I am writing that compiles a list of Performance Counter Categories,Instances, and Counters on that System. It builds a xml document and returns that. The first time the method is called after being published to the server, it takes about 17 seconds to get a result. Each time it is called after that, it takes 38 seconds. If I republish, the first time after that takes 17 seconds and then I am back at 38 seconds per a call.

    [WebMethod(Description="Returns the CounterList in XML Format")]
    public XmlDocument GetCounters()
    {
        XmlDocument CounterList = new XmlDocument();
        XmlElement root = CounterList.CreateElement("CounterList");
        PerformanceCounterCategory[] pcc = PerformanceCounterCategory.GetCategories();
        foreach (PerformanceCounterCategory cat in pcc)
        {
            XmlElement Category = CounterList.CreateElement("Category");
            XmlAttribute CatName = CounterList.CreateAttribute("Name");
            CatName.Value = cat.CategoryName;
            Category.Attributes.Append(CatName);
            String[] instances = cat.GetInstanceNames();
            PerformanceCounter[] pc;
            if (instances.Length > 0)
            {
                pc = cat.GetCounters(instances[0]);
                XmlElement Instances = CounterList.CreateElement("Instances");
                foreach (String instance in instances)
                {
                    XmlElement Instance = CounterList.CreateElement("Instance");
                    Instance.AppendChild(CounterList.CreateTextNode(instance));
                    Instances.AppendChild(Instance);
                }
                Category.AppendChild(Instances);
            }
            else
                pc = cat.GetCounters();

            XmlElement Counters = CounterList.CreateElement("Counters");
            foreach (PerformanceCounter counter in pc)
            {
                XmlElement Counter = CounterList.CreateElement("Counter");
                Counter.AppendChild(CounterList.CreateTextNode(counter.CounterName));
                Counters.AppendChild(Counter);
            }
            Category.AppendChild(Counters);
            root.AppendChild(Category);
        }
        CounterList.AppendChild(root);
        return CounterList;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:07:56+00:00Added an answer on May 23, 2026 at 8:07 am

    I would comment out this line:

    PerformanceCounterCategory[] pcc = PerformanceCounterCategory.GetCategories();
    

    and see if the symptom persists.

    Note, I tried the code as a regular function and the first one took about 4 seconds, subsequent executions took about .2 seconds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Web Service with Just one Web Method that returns a boolean
I have a web service (ASMX) and in it, a web method that does
I have a method in my web service which returns a DataView, I have
I have a web service method where I would like to throw some custom
I have a web service method in which I create a particular type of
If I have a web service method, e.g. [WebMethod] [XmlInclude(typeof(SportsCar)), XmlInclude(typeof(FamilyCar))] public Car[] GetCars()
I do have something more specific in mind, however: Each web service method needs
Say I have an ASMX web service, MyService. The service has a method, MyMethod.
When I call, the service's method, I have Web Service Exception happening which I
We have 1000 threads that hit a web service and time how long the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.