Here is the Code given on the Boost library documentation.
#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
void print(const boost::system::error_code& /*e*/)
{
std::cout << "Hello, world!
";
}
int main()
{
boost::asio::io_service io;
boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
t.async_wait(print);
io.run();
return 0;
}
Now when I run the above program it just waits for 5 seconds and then prints Hello World and stop. I want this program to keep printing Hello World every 5 seconds. Is it possible ?
See Question&Answers more detail:os