Can code stop loading if the loading take too long time?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Can code stop loading if the loading take too long time?

Postby slothsimon » Tue Mar 07, 2017 3:12 am

Hi,

I am using cef Branch2623 and I saw CefLoadHandler only have 4 functions: OnLoadingStateChange, OnLoadStart, OnLoadEnd and OnLoadError.

I want to stop loading if the loading(or receiving response from server) take too long time, so how can i do that? Or is there anything I can config the time wait for loading?

Also I want to know if I can make the page show a page used for waiting and when the actual page has loaded then replace the waiting page with the actual page?

Thank you!
slothsimon
Newbie
 
Posts: 9
Joined: Wed Feb 08, 2017 8:44 pm

Re: Can code stop loading if the loading take too long time?

Postby Czarek » Thu Mar 09, 2017 1:42 am

You can call CefBrowser.StopLoad method. In OnLoadingStateChange you could post a CEF delayed task (eg. 30sec) using CefPostDelayedTask that would stop loading. In OnLoadigStateChange when page completes you could cancel that task. There is no function in CEF to cancel a task that was already posted, however you could add some additional logic in your code to accomplish such functionality.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Can code stop loading if the loading take too long time?

Postby slothsimon » Thu Mar 09, 2017 4:00 am

This is very useful! I will use it in my program.
Thank you so much!
slothsimon
Newbie
 
Posts: 9
Joined: Wed Feb 08, 2017 8:44 pm

Re: Can code stop loading if the loading take too long time?

Postby tejohnso » Tue Jan 15, 2019 10:47 pm

> There is no function in CEF to cancel a task that was already posted,

What about combining a CefPostDelayedTask with a cef_cancelable_callback?
There's an example in the header

I'm testing that and it seems to work. If I don't call cancel() my callback is called and I see my test log output. If I do call cancel, there is no log output.

However, when I don't cancel, I'm getting a message indicating "MojoDiscardableSharedMemoryManagerImpls are still alive. They will be leaked." So I'm not sure the combination is correct.
tejohnso
Newbie
 
Posts: 6
Joined: Tue Jan 15, 2019 10:34 pm


Return to Support Forum

Who is online

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