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

  • Home
  • SEARCH
  • 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 1054743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:27:13+00:00 2026-05-16T17:27:13+00:00

I am writing a C# application that needs to be able to tell how

  • 0

I am writing a C# application that needs to be able to tell how much time it takes for a certain application to open. I am using the Stopwatch class as my timer. Start time is easy since I set it exactly with the call to run the .exe. The problem is finding out how to time when the program is done opening. The only thing I could think of to test this is using a PerformanceCounter object and checking when CPU% is less than a certain number using a while loop.

At the moment I am using PerformanceCounter, but I am not having luck with it displaying the CPU% (it’s always displaying 0). My guess for this is either that the application opens up faster than the PerformanceCounter can check for the CPU% or that the PerformanceCounter is not seeing the process name because I’m calling it too quickly (I highly doubt the latter due to the fact that I think I would get errors if this happened).

Are there any other ways to have this problem solved? Is there something I might be doing wrong that is giving me a 0 CPU% all the time? I am not looking for external tools outside of my application. Here is a sample of my code:

otherApp = new otherApplication.Application();
PerformanceCounter cpuCounter = new PerformanceCounter("Process",
"% Processor Time", "otherApplication");
//This next line is to check if PerformanceCounter object is working
//MessageBox.Show(cpuCounter.NextValue().ToString());
stopwatch.Start();
while (cpuCounter.NextValue() > 10)
{
}
stopwatch.Stop();

Edited: Changed code to say otherApp and otherApplication instead of myApp and myApplication, so that it may be easier to understand.

  • 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-16T17:27:14+00:00Added an answer on May 16, 2026 at 5:27 pm

    You may be better off using a known location in your code (a particular method that’s called when all initialization work is complete) rather than relying on CPU utilization as a heuristic.

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

Sidebar

Related Questions

So, I'm writing a Cocoa application that needs to be able to display web
I am writing an application that needs to be able to locate to a
I'm writing a Rails 3 application that needs to be able to trigger modifications
I'm writing a client/server application that requires the server needs to be able to
I am writing a quick-and-dirty in-house ASP.NET application that needs to be able to
I am writing an application that needs to bring window of an external app
I am writing an application that needs to send data over a network. I
I'm writing an application that needs a log-like view, (similar to how an IM
I am writing an application in C# that needs to run as a service
I'm writing a query for an application that needs to list all the products

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.