I'm trying to dynamically add directories from a config file before I enter my programs main loop using the ASIO dir monitor example. I've not been
able to understand the internals yet. Below is my current iteration of what
I'm trying. I have been able to get the simple examples running just like in the async.cpp file. But I can't get adding dirs dynamically working and was hoping someone could offer suggestions.

Any help much appreciated.

void my_file_handler(const boost::system::error_code &ec,
    const boost::asio::dir_monitor_event &ev)
{
    // event stuff ...

    return;
}


    boost::asio::dir_monitor *dm;
    boost::asio::io_service io_service;
    vector<boost::asio::dir_monitor *> vecdm;

    for (vector<Directories>::iterator it = dirs->begin();
            it != dirs->end(); ++it) {
        dm = new boost::asio::dir_monitor(io_service);
        dm->add_directory((*it).abs_dir_path);
                      
        vecdm.push_back(dm);
    }
   
    boost::thread t =
        boost::thread(boost::bind(&boost::asio::io_service::run,
            boost::ref(io_service)));
                
    while (true) {
        // MAIN PROGRAM LOOP

        for (vector<boost::asio::dir_monitor *>::iterator it =
            vecdm.begin(); it != vecdm.end(); ++it) {
           
            (*it)->async_monitor(my_file_handler);
        }
       
        io_service.reset();

        // DO PROGRAM STUFF ...
    }
~                                                                              
~