Using multitherad under the CefResourceHandler

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Using multitherad under the CefResourceHandler

Postby saykou » Thu Dec 22, 2016 4:49 am

Is it possible to use multi thread under the Resource handler, the cef application started to behave badly after this, i wonder if it is a problem of thread safety on my underlying code, or is CEF that can't handle mutlithread in this section of the code.

I have something like this.

Code: Select all

      virtual bool ProcessRequest(CefRefPtr<CefRequest> request, CefRefPtr<CefCallback> callback)
         OVERRIDE {
         CEF_REQUIRE_IO_THREAD();
         
                        CefPostTask(TID_FILE, base::Bind(&MyCefResourceHandler::asyncExecute, this, request->GetURL(), callback));
         return true;
      }

      void asyncExecute(std::string url, CefRefPtr<CefCallback> callback)
      {
         std::thread asyncExecute(&MyCefResourceHandler::execute, this, url, callback);
         asyncExecute.detach();
      }
      void execute(std::string url, CefRefPtr<CefCallback> callback) {
         //code
         callback->Continue();
      }


thanks in advance.
saykou
Techie
 
Posts: 23
Joined: Wed May 06, 2015 6:22 am

Re: Using multitherad under the CefResourceHandler

Postby amaitland » Thu Dec 22, 2016 6:03 pm

Any method that provides s callback is meant to be used in an asynchronous fashion.

Reading the data in an asynchronous fashion is a little more complicated see https://bitbucket.org/chromiumembedded/ ... ew-default
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am


Return to CEF Discussion

Who is online

Users browsing this forum: Google [Bot] and 22 guests