determine the current process

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

determine the current process

Postby teremy » Fri Apr 21, 2017 10:14 am

Hello.
Is there a method that let's me check for the current process in my code?
I need to do some stuff only on the browser process. The problem right now is that code gets executed on browser and renderer process.
I need to execute some code only on the browser code.

Here is more info on the scenario:
I have a static class ( class with static members ) that is my data model. The data is updated in the browser process but not in the renderer process ( because I am not sending the renderer process this data ).
The data model fires events depending on its changes and I create an object that subscribes to these events. This object is created in the browser AND the renderer process, which is not what I want. I want only the browser process to subscribe to the events of the data model.
If I could have something like if(CurrentProcess == BrowserProcess){...} then I think I'd be fine.

Thanks in advance.

EDIT: I know I can check for CEF Threads, but I am running threads besides CEF ( WinForms runs it's own thread I think and I also do some networking stuff and listening in another thread ). Also I can't check for the Renderer Thread, because I get an exception if I do that in the browser process.
teremy
Techie
 
Posts: 15
Joined: Mon Aug 22, 2016 8:51 am

Re: determine the current process

Postby fddima » Fri Apr 21, 2017 10:29 am

Hello.

You client code should call CefRuntime.Initialize for browser process. So if you need to know that it is browser process - set some static field/property near this call.

Alternative: examine arguments passed to main, switch prefixed with --type= will hold process type. Or doesn't have this for browser process.
fddima
Master
 
Posts: 774
Joined: Tue Dec 07, 2010 6:10 am

Re: determine the current process

Postby teremy » Fri Apr 21, 2017 1:56 pm

Exactly what I needed to know. You even answered within 15 minutes, you are awesome, I love you.
teremy
Techie
 
Posts: 15
Joined: Mon Aug 22, 2016 8:51 am


Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 1 guest