Your code doesn't compile because you're trying to invoke a pointer to a member function, without passing the object to invoke it on.
KWxAPI::syncUpdate
needs a KWxAPI
object to use as it's this
pointer, but you aren't passing one. Any time you try to invoke a pointer-to-member function, such as this, you need to pass the this
pointer it should use as the first parameter.
std::async(std::launch::async, &KWxAPI::syncUpdate, this, no_interact);
Aside from this, you should be aware that KWxAPI::syncUpdate
will execute in another thread, but your std::async
statement will block until that thread finishes executing the function.
This is because std::async
returns an std::future
object, which is destructed at the end of your std::async
statement, because you aren't storing it anywhere. In it's destructor, it blocks until execution has completed.