Hi,
There are several ways to get JavaScript results. I haven't tested this way but I think it should work.
Unless there's some unexpected problem executing JavaScript at 300 ms intervals you should be able to receive the results in the TChromium.OnConsoleMessage event.
Please, don't use the single process mode unless you want to debug other processes. This mode is NOT supported by CEF3 and it's known to cause errors and access violations.
It's also recommended to use GlobalCEFApp.MultiThreadedMessageLoop := TRUE in Windows.
Remember that the TChromium.OnConsoleMessage event is executed in a thread. I would use synchronization objects to store the JSON text and exit from that event as soon as possible without parsing the text or storing it in the database.
Post a message to the main form every time a new JSON text is stored to parse the JSON text and store the results in the database.
The text parsing should be done in a different thread to have a responsive user interface.
Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Migration from CEF1 on CEF3
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Migration from CEF1 on CEF3
I'm sorry but that's out of the scope of CEF4Delphi's project.
All demos are related to CEF4Delphi's functionality but here you can find more info about Delphi threads :
http://docwiki.embarcadero.com/RADStudi ... plications
https://www.safaribooksonline.com/libra ... /ch04.html
http://www.thedelphigeek.com/2012/02/bl ... -four.html
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Migration from CEF1 on CEF3
Some apps need to show a browser inside a customized GUI, for example a game might want to show a web page inside a 3D scene.
If I remember correctly, OSR mode is used in some other platforms.
Windows has limitations for the amount of resources a process is using, number of subprocesses created by a process, etc.parserMan wrote: ↑Mon Mar 26, 2018 3:15 pm In the future i need to parse 10 000 pages in the same time by JS script))) (it is very ambitious target)))
I have to use OSR mode? (By some reasons i cant use simple GET http method. All these pages are formed by JS on client side, and every second content are change)
You will need several HUNDRED computers to do that.
You can receive the results from JavaScript in other ways like CEF process messages, customized process messages and websockets.
Some demos in the JavaScript directory use CEF process messages.
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Migration from CEF1 on CEF3
If you use TChromium and TCEFWindowParent this is the destruction sequence :
- 1. FormCloseQuery sets CanClose to False and calls TChromium.CloseBrowser, which triggers the TChromium.OnClose event.
- 2. TChromium.OnClose sends a message to the form to destroy TCEFWindowParent in the main thread, which triggers the TChromiumWindow.OnBeforeClose event.
- 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Migration from CEF1 on CEF3
You can send a custom message from the Chromium0BeforeClose procedure to the main form to free chromium0 in the main app thread.
Your code should work but you can take a llok at the MDIBrowser, ToolBoxBrowser or any other demo with an external pump to see see how to destroy browsers safely. Some of the demos use different components and the destruction sequence is slightly different but all of them follow the CloseBrowser -> OnClose -> OnBeforeClose sequence.
Your code should work but you can take a llok at the MDIBrowser, ToolBoxBrowser or any other demo with an external pump to see see how to destroy browsers safely. Some of the demos use different components and the destruction sequence is slightly different but all of them follow the CloseBrowser -> OnClose -> OnBeforeClose sequence.