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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:56:14+00:00 2026-05-18T09:56:14+00:00

First let me introduce the application scene: I have a service application which is

  • 0

First let me introduce the application scene:

I have a service application which is spying the status of something, while also have multiple applications waiting for the status to change. Once the status is changed, each application will read the status value (via a named FileMap object) and execute corresponding actions, and then wait for the status to be changed again.

So I used a named Event object to do the synchronization work. All applications are waiting for this event to be signaled, and the service application will set this event to be signaled when that status is changed.

I need to guarantee that when the status is changed, each waiting application will be released and is released only once!

I have tried with these 2 methods

Method 1

  1. Create a manual reset event;
  2. When the status is changed, first call SetEvent, then call ResetEvent immediately.

Method 2

  1. Create a manual reset event;
  2. When the status is changed, call PulseEvent.

Both methods seem work well during the test. But I think neither of them is reliable because:

For ## Method 1 ##, maybe some of the waiting threads won’t get chance to be executed before the ResetEvent function is called.

For ## Method 2 ##, Microsoft has claimed PulseEvent is unreliable and should not be used.

Is there any workable solution for this case? Any advice is welcome.

  • 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-18T09:56:14+00:00Added an answer on May 18, 2026 at 9:56 am

    There is no way this can be safely implemented with O(1) synchronization primitives.

    To inform N applications about new status change use N events. Service should set them all, and every application should reset its corresponding event upon handling the current status change.

    To wait until all applications handle new status change service can use another set of N events and WaitForMultipleObjects with bWaitAll==TRUE. Each application should set its corresponding event.

    So, service does a loop: observe status change, write to shared memory, set all A events, wait on all B events, reset all B events, continue loop. Every application does a loop: wait on its A(i) event, reset A(i), handle status change, set B(i), continue loop.

    Both A and B events can be of auto-resetting type. Then you don’t have to reset anything.

    If you feel green and don’t want to waste resources you can use some sort of reversed semaphore instead of B set of events. This can be implemented with one shared counter synchronized by mutex and one event (B’) to notify the service. Instead of waiting on whole B set the service waits on B’ and when wait is over set the counter to N. Instead of setting its B(i) event each application should decrement the counter, and if counter drops to zero that last application should set only B’.

    You can’t bypass the A set of events. The problem is not in setting the A event but in resetting. By resetting its A(i) event the application will not miss another status change. And it is not helpful to use semaphore here.

    Note that this solution does not take into account possible crash of an application. If that happens the service will wait forever for non-existing application to respond.

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

Sidebar

Related Questions

let me introduce my story first. To develop a multiplayer network game in facebook,
First let me say that I really feel directionless on this question. I am
First, let's get the security considerations out of the way. I'm using simple authentication
Let's say the first N integers divisible by 3 starting with 9. I'm sure
First, let me explain what I am doing. I need to take an order,
First, let me use one sentence to let out some frustration: My god, developing
First, let me say that I'm a complete beginner at Python. I've never learned
Let me state first: I know that any user that wants to run a
Alright let me explain my situation first: I am part of an organization that
First off, let me start off that I am not a .net developer. 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.