Hello,
I have an image processing call (about 5 to 10 second) inside a ProcessRequest() and my XHR is async, but the UI still freeze.
Is there any thing to do such as using callback function or use threading ?
Regards,
Alex
bool ProcessRequest(CefRefPtr<CefRequest> request, CefRefPtr<CefCallback> callback)
{
if ( strstr(url.c_str(), "myaction") != NULL )
{
std::async(&RunLongProcess, this, request->GetPostData(), callback);
return true; // Handled request;
}
// Dont put the Callback->Continue() here, reserve it for your thread.
return false;
}
void RunLongProcess(CefRefPtr<CefPostData> postData, CefRefPtr<CefCallback> callback)
{
// Check if postData has been provided.
if ( postData == NULL )
Callback->Cancel(); // Cancel the request.
// processing ...
// Similar to other ProcessRequest set the m_data and your m_mime_type (if you have one).
// Then send to the factory, that the request is finished to process
// and it can now call the GetResponseHeaders and ReadResponse.
Callback->Continue();
}
bool ProcessRequest(CefRefPtr<CefRequest> request, CefRefPtr<CefCallback> callback)
{
if ( strstr(url.c_str(), "myaction") != NULL )
{
std::thread(&RunLongProcess, this, request->GetPostData(), callback).detach();
return true; // Handled request;
}
// Dont put the Callback->Continue() here, reserve it for your thread.
return false;
}
Users browsing this forum: Google [Bot] and 60 guests