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 8687335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:05:37+00:00 2026-06-12T23:05:37+00:00

What is the benefit of using WaitForSingleObject here as opposed to not using it?

  • 0

What is the benefit of using WaitForSingleObject here as opposed to not using it? The first block of code is from a previous answer. The second block is how I am doing it.

BOOL IsProcessRunning(DWORD pid)
{
    HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, pid);
    DWORD ret = WaitForSingleObject(process, 0);
    CloseHandle(process);
    return (ret == WAIT_TIMEOUT);
}

vs

BOOL IsProcessRunning(DWORD pid)
{
   HANDLE process = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
   const bool exists = (process != NULL);
   CloseHandle(process);
   return exists;
}

It seems like using SYNCHRONIZE requires higher privileges and I only want to check the PID for the current user.

  • 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-06-12T23:05:38+00:00Added an answer on June 12, 2026 at 11:05 pm

    When a process completes, it stops running but it doesn’t go out of existence until the last handle to it is closed. The first solution distinguishes between those two states (still running or done running). Of course, the answer could be obsolete by the time it has returned.

    If you don’t need that distinction, then your approach is fine (though I would name the function something like DoesProcessExist).

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

Sidebar

Related Questions

I'm using c#. In many cases I'm writing code that can benefit from a
I am working on releasing an app that will greatly benefit from using the
I have a few .Net projects that would benefit from using a document/object database
In the following code, what is the benefit of using (!!p) instead of (p
What is the practical benefit to keep CSS 100% validated (not using any hacks),
What's the benefit of using InputStream over InputStreamReader , or vice versa. Here is
I am about 90% sure my program would benefit from using the document framework
I have a very simple case that I think would benefit from using templates
What is the benefit of using NSNumber from Foundation Framework instead of basic C
When can I get better performance using memcpy or how do I benefit from

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.