I'm following the examples given in the GeneralUsage wiki Posting Tasks section but I'm getting these compile errors:
Error C2027 use of undefined type 'base::OnceCallback<void (void)>'
Error C2665 'CefPostTask': none of the 3 overloads could convert all the argument types
Attempting to compile this code from the wiki in a separate module gives the same errors for both bind::Once() calls
- Code: Select all
#include "cef_callback.h"
#include "cef_ref_counted.h"
#include "cef_closure_task.h"
#include "cef_helpers.h"
// Define a function.
void MyFunc(int arg) { /* do something with |arg| on the UI thread */ }
// Post a task that will execute MyFunc on the UI thread and pass an |arg|
// value of 5.
void doBind() {
CefPostTask(TID_UI, base::BindOnce(&MyFunc, 5));
}
// To execute a bound method:
// Define a class.
class MyClass : public CefBaseRefCounted {
public:
MyClass() {}
void MyMethod(int arg) { /* do something with |arg| on the UI thread */ }
private:
IMPLEMENT_REFCOUNTING(MyClass);
};
void doBindMethod() {
// Create an instance of MyClass.
CefRefPtr<MyClass> instance = new MyClass();
// Post a task that will execute MyClass::MyMethod on the UI thread and pass
// an |arg| value of 5. |instance| will be kept alive until after the task
// completes.
CefPostTask(TID_UI, base::BindOnce(&MyClass::MyMethod, instance, 5));
}
Any help would be greatly appreciated.