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

The Archive Base Latest Questions

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

I am currently writing a program that will run mulitple programs in groups all

  • 0

I am currently writing a program that will run mulitple programs in groups all at once and others on their own.


if( WAIT_FAILED == WaitForMultipleObjects(numberOfProgramsRan, &information[i].hProcess, TRUE, INFINITE) ) {
wcerr << L"Failure waiting for process" << endl;
}

numberOfProgramsRan is the number of programs that i ran in my loop.
&information[i] is a vector holding my process information from the create process

When i create the process in a for loop my program will wait if there are two or less processes being created (so two programs being passed in to run) before it runs my next processes.
If create more than two processes (or pass in more than two programs in my vector) my WaitForMultipleObjects it fails.

If i need to futher explain my issue please let me know.

Thanks for your help

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

    If you only wait on a single process (index i) you should use WaitForSingleObject. If you’re waiting on multiple processes you need to pass in an array of handles as others have said – not a pointer into PROCESS_INFORMATION.
    If you insist on using WaitFoRmultipleObjects for a single object use:

    WaitForMultipleObjects(1, &information[i].hProcess, TRUE, INFINITE)
    

    If you use anything other than 1 then look at the definition of PROCESS_INFORMATION:

    typedef struct _PROCESS_INFORMATION {
      HANDLE hProcess;
      HANDLE hThread;
      DWORD  dwProcessId;
      DWORD  dwThreadId;
    } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
    

    The following dwProcessId and dwThreadID will then be incorrectly treated as handles your call will not work as expected.

    Something like:

    HANDLE hProcess[MAX_PROCESSES];
    for(int i=0; i<numberOfProgramsRan; i++)
    {
      hProcess[i] = information[i].hProcess;
    }
    WaitForMultipleObjects(numberOfProgramsRan, hProcess, TRUE, INFINITE);
    

    Will wait on all your processes.

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

Sidebar

Related Questions

I am currently writing a program that will read part of the windows system
Hey guys, Im working with wpf 3d, im currently writing a program that will
Since I am writing a program that will eventually run on Windows and Linux
I am writing a program that generates excel reports, currently using the Microsoft.Interop.Excel reference.
I'm currently writing a program that needs to compare each file in an ArrayList
I'm writing a Linux program that currently compiles and works fine on x86 and
I am writing a program that will draw a solid along the curve of
I'm writing a program that, using Rijndael, will encrypt and decrypt files/folders using a
At the office we are currently writing an application that will generate XML files
I am writing a program that will basically make a xml copy of most

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.