<div dir="ltr">It looks like my problems aren&#39;t with the timer at all. This listing pretty much mimicked example 3.<div>It ends up that my problem is that if you click on a console window in windows 10, the program ceases execution when it enters &quot;quick edit&quot; mode. I was not aware of that new behavior and thought the timer was not working. The program run fine, as is, if you don&#39;t touch the mouse.<br><br>Sorry, false alarm.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 11, 2019 at 7:42 PM Christopher Pisz &lt;<a href="mailto:christopherpisz@gmail.com">christopherpisz@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I am trying to perform a task on an interval and I made a POC using boost::asio::steady_timer. When I debug it, it only performs the callback once and does not fire again. I am not sure what I am doing wrong. Any suggestions?<div><br></div><div>    // DoMouseEvents.cpp : This file contains the &#39;main&#39; function. Program execution begins and ends there.<br>    //<br><br>    #include &lt;boost/asio.hpp&gt;<br>    #include &quot;boost/asio/deadline_timer.hpp&quot;<br>    #include&lt;boost/bind.hpp&gt;<br>    #include &lt;chrono&gt;<br>    #include &lt;iostream&gt;<br><br>    class Pooper<br>    {<br>        boost::asio::io_context &amp; m_ioContext;<br>        boost::asio::steady_timer m_timer;<br><br>    public:<br>        Pooper(boost::asio::io_context &amp; ioContext)<br>            :<br>            m_ioContext(ioContext)<br>            , m_timer(boost::asio::steady_timer(ioContext))<br>        {<br>        }<br><br>        void Run()<br>        {<br>            m_timer.expires_from_now(std::chrono::seconds(5));<br>            m_timer.async_wait(boost::bind(&amp;Pooper::OnTimerExpired, this, boost::asio::placeholders::error));<br>        }<br><br>        void OnTimerExpired(const boost::system::error_code &amp; error)<br>        {<br>            if (error.failed())<br>            {<br>                std::cerr &lt;&lt; &quot;boost error: Failed&quot; &lt;&lt; std::endl;<br>            }<br><br>            std::cout &lt;&lt; &quot;Poop&quot; &lt;&lt; std::endl;<br><br>            try<br>            {<br>                // Move the mouse<br>                int x = 500;<br>                int y = 500;<br>                if (!::SetCursorPos(x, y))<br>                {<br>                    int errorCode = GetLastError();<br>                    std::cerr &lt;&lt; &quot;SetCursorPos error: &quot; &lt;&lt; errorCode &lt;&lt; std::endl;<br>                }<br><br>                // Left button down<br>                x = 65536 * 500;<br>                y = 65536 * 500;<br>                ::mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN, x, y, NULL, NULL);<br><br>                // Left button up<br>                x = 65536 * 500;<br>                y = 65536 * 500;<br>                ::mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP, x, y, NULL, NULL);<br><br>                m_timer.expires_from_now(std::chrono::seconds(5));<br>                m_timer.async_wait(boost::bind(&amp;Pooper::OnTimerExpired, this, boost::asio::placeholders::error));<br>            }<br>            catch (std::exception &amp;)<br>            {<br>                std::cerr &lt;&lt; &quot;An exception occured.&quot; &lt;&lt; std::endl;<br>            }<br>        }<br>    };<br><br>    int main()<br>    {<br>        boost::asio::io_context ioContext;<br>        auto pooper = Pooper(ioContext);<br>        pooper.Run();<br>        ioContext.run();<br><br>        std::cerr &lt;&lt; &quot;Exited...&quot; &lt;&lt; std::endl;<br>    }<br><br></div></div>
</blockquote></div>