
Environment: Windows XP Boost 1.40 Problem: Canceling an asio::deadline_timer doesn't pass an operation_aborted value to the timer handler. --------------- From the async_wait doc: For each call to async_wait(), the supplied handler will be called exactly once. The handler will be called when: * The timer has expired. * The timer was cancelled, in which case the handler is passed the error code boost::asio::error::operation_aborted. --------------- When I call my Restart() function (which calls the cancel() function) my TimerHandler() receives an err value of 0. When the timer is allowed to expire, the TimerHandler doesn't get called at all. Thoughts? - Bruce Here's the relevant code: boost::asio::io_service mIOService; boost::asio::deadline_timer mTimer(mIOService, boost::posix_time::seconds(3)) inline void TimerHandler(const boost::system::error_code& err) { cout << err; if (err && err != boost::asio::error::operation_aborted) { cout << endl << "Watchdog elapsed" << endl; } } void Start() { mTimer.async_wait(TimerHandler); mIOService.run(); } // Cancels and restarts the watchdog timer - prevents a timeout void Restart() { mTimer.cancel(); mTimer.async_wait(TimerHandler); mIOService.reset(); mIOService.run(); }