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.
Second instance of .exe fails
Re: Second instance of .exe fails
Thank you so much! I finally got it all working!
Re: Second instance of .exe fails
Hi all,
Is there a way to use more instances of my application or not? If yes, can someone demonstrate how to accomplish this task?
Thanks
Is there a way to use more instances of my application or not? If yes, can someone demonstrate how to accomplish this task?
Thanks
- salvadordf
- Posts: 4374
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Second instance of .exe fails
Yes. You can run a second instance of your application as long as each instance uses a different cache directory in the GlobalCEFApp.cache property.
If you need to use the same cache and cookies in all your instances then follow the instructions about using a MUTEX in my previous posts on this thread.
Re: Second instance of .exe fails
Thanks for your answer. Sounds good, does this directory have to exist on the hard drive? Maybe you could provide me a short piece of code to demonstrate that (best practice), also this way with the mutex? (Sorry, but there are so many code snippets in the previous posts)
Last edited by Bilbo on Tue Mar 05, 2024 1:54 pm, edited 2 times in total.
Re: Second instance of .exe fails
I just created 2 executables that use different caches (GlobalCEFApp.Cache := ...). However, both cannot be started at the same time. Could you perhaps post an example of how this works?
Last edited by Bilbo on Wed Mar 06, 2024 8:20 am, edited 1 time in total.
- salvadordf
- Posts: 4374
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Second instance of .exe fails
Follow these steps :
If necessary, you can also set GlobalCEFApp.RootCache := 'c:\root1'; and then set GlobalCEFApp.cache := 'c:\root1\cache';
The second executable should set GlobalCEFApp.RootCache := 'c:\root2'; and then set GlobalCEFApp.cache := 'c:\root2\cache';
- Open the SimpleBrowser2 demo and edit the project source.
- Add this line before the GlobalCEFApp.StartMainProcess call : GlobalCEFApp.cache := 'cache1';
- Build SimpleBrowser2.
- Open the CEF4Delphi\bin directory and rename SimpleBrowser2.exe to SimpleBrowser2-cache1.exe
- Edit the project source again and set GlobalCEFApp.cache := 'cache2';
- Build SimpleBrowser2 again.
If necessary, you can also set GlobalCEFApp.RootCache := 'c:\root1'; and then set GlobalCEFApp.cache := 'c:\root1\cache';
The second executable should set GlobalCEFApp.RootCache := 'c:\root2'; and then set GlobalCEFApp.cache := 'c:\root2\cache';
Re: Second instance of .exe fails
Thank you, that's how it works.
Now I have the problem that I want to delete the cache directory at the end of the application otherwise there would be a lot of directories after a while. But that doesn't work because Chromium still has access to the cache directory even after releasing the instance (CEFApp.Free). How can I accomplish this task?
Now I have the problem that I want to delete the cache directory at the end of the application otherwise there would be a lot of directories after a while. But that doesn't work because Chromium still has access to the cache directory even after releasing the instance (CEFApp.Free). How can I accomplish this task?
- salvadordf
- Posts: 4374
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Second instance of .exe fails
Try calling TChromiumCore.ClearCache before closing the application. Wait for the TChromiumCore.OnDevToolsMethodResult event before closing the application.
You can also save a custom setting or registry value to mark that directory as "deletion pending". Then modify the application to delete it before initializing CEF when it starts.
GlobalCEFApp.DeleteCache can also be used to delete the cache before initializing CEF.
You can also save a custom setting or registry value to mark that directory as "deletion pending". Then modify the application to delete it before initializing CEF when it starts.
GlobalCEFApp.DeleteCache can also be used to delete the cache before initializing CEF.
Re: Second instance of .exe fails
I'm not able to call TChromiumCore in my dpr file. I don't think this is of any use to me either because I don't open a browser window. I close the application again immediately after opening it. DeleteCache doesn't help. Any other idea?
- salvadordf
- Posts: 4374
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Second instance of .exe fails
The previous methods to clear the cache is what CEF and Chromium allows us to use.
We can only adapt our applications to the existing CEF methods.
We can only adapt our applications to the existing CEF methods.