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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:09:16+00:00 2026-05-26T05:09:16+00:00

I have a simple application which spawns two threads and assigns one with a

  • 0

I have a simple application which spawns two threads and assigns one with a task of processing some file and saving the result to another one, while the other thread retrieves information about it’s parent process.
I’m using some manual reset events and a FindFirstChangeNotification function. The primary thread enters an infinite loop, inside calling WaitForMultipleObjectsEx.

Here’s the snippet:

while(TRUE){
waitResult = WaitForMultipleObjectsEx(4, eventObjectHandles, FALSE, 5000, FALSE);
    switch(waitResult){
        case WAIT_OBJECT_0 + 0:
            _tprintf(_T("\nThread with ID: %d has finished processing the poem.\n"), threadIds[0]);
            _tprintf(_T("Output file path: %s\n"), thread_xyz_param.outputPath);
            ResetEvent(eventObjectHandles[0])
            break;
        case WAIT_OBJECT_0 + 1:
            ResetEvent(eventObjectHandles[1]);
            break;
        case WAIT_OBJECT_0 + 2:
            _tprintf(_T("Error in thread with ID: %d!\n"), threadIds[0]);
            ResetEvent(eventObjectHandles[2]);
            break;
        case WAIT_OBJECT_0 + 3:
            _tprintf(_T("Error in thread with ID: %d!\n"), threadIds[1]);
            ResetEvent(eventObjectHandles[3]);
            break;
    }

    GetExitCodeThread(threadHandles[0], &firstThreadStatus);
    GetExitCodeThread(threadHandles[1], &secondThreadStatus);

    if((firstThreadStatus != STILL_ACTIVE) && (secondThreadStatus != STILL_ACTIVE)){
        break;
    }
}

Problem is that the the FindFirstChangeNotification function is signalling multiple times, even though I write to the output file only once.
Is it a good idea to call FindCloseChangeNotification instead of ResetEvent?

Thanks in advance!

  • 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-26T05:09:16+00:00Added an answer on May 26, 2026 at 5:09 am

    The handle returned by FindFirstChangeNotification cannot be passed to ResetEvent. If you want to wait for another event, use FindNextChangeNotification. If you are finished with it, then use FindCloseChangeNotification.

    This is implied by the documentation: “If the function succeeds, the return value is a handle to a find change notification object.” It returns a handle to a find change notification object, not an event. Therefore, it is an invalid parameter to ResetEvent.

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

Sidebar

Related Questions

I have this simple MVC 3 application which simply has two controllers(Home and Edit),
I have a simple console application which runs daily (called by windows task scheduler)
I have a simple C# 2008 application which displays a png-picture and handles some
I have create a simple application which using C++ and produce a executable file.
I have a simple application which was working fine until I added some code
I have a simple WebView application which takes some time to load up when
I have a simple WPF application which I am trying to start. I am
I have a relatively simple application which I need to make native Mac OSX
I have a simple iPhone application which uses OpenGL ES (v1) to draw a
I have a simple application in which I need to let the user select

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.