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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:34:34+00:00 2026-05-25T22:34:34+00:00

My program needs to gracefully terminate when a Windows event becomes signaled. I am

  • 0

My program needs to gracefully terminate when a Windows event becomes signaled. I am using Boost’s ASIO library for it’s sockets. I only have one io_service object. How can I ‘register’ this event handle with the io_service, so it calls a callback when the event signals?

  • 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-25T22:34:35+00:00Added an answer on May 25, 2026 at 10:34 pm

    If you’re looking for termination handling on Windows for Boost.Asio you can take a look at the examples here.

    In short, you need to handle the win events and call stop on your system.

    BOOL WINAPI console_ctrl_handler(DWORD ctrl_type)
    {
      switch (ctrl_type)
      {
        case CTRL_C_EVENT:
        case CTRL_BREAK_EVENT:
        case CTRL_CLOSE_EVENT:
        case CTRL_SHUTDOWN_EVENT:
          console_ctrl_function();
          return TRUE;
        default:
          return FALSE;
      }
    }
    

    This uses a function object:

    boost::function0<void> console_ctrl_function;
    

    that you need to bind to your system’s shutdown/stop routine.

    // Set console control handler to allow server to be stopped.
    console_ctrl_function = boost::bind(&your_system::shutdown, &s);
    SetConsoleCtrlHandler(console_ctrl_handler, TRUE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of PDF files and my Perl program needs to do
I have a program which needs to behave slightly differently on Tiger than on
I have a Java program using a basic Hibernate session factory. I had an
We have an installation program that runs in Perl 32-bit. This program needs to
I have a C# Console app in VS C# Express 2008. The program needs
A python program needs to draw histograms. It's ok to use 3rd party library
Let's say I have a simple config file that my c program needs to
I'm trying to compile a C++ program under Ubuntu 11.10 using boost 1.42 installed
I have run into a datetime related problem, my program needs to varify whether
I have a very large text file, and my iPad program needs to occasionally

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.