GeckoFX

Skybound

Skybound Software is looking to hire experienced C# developers to work on Stylizer and other forthcoming Skybound products. Click here for details.

GeckoFX is an open-source component which makes it easy to embed Mozilla Gecko (Firefox) into any .NET Windows Forms application. Written in clean, fully commented C#, GeckoFX is the perfect replacement for the default Internet Explorer-based WebBrowser control. Download GeckoFX @ Google Code >

GeckoFX is made by Skybound Software, authors of Stylizer—the professional CSS editor with a strong focus on visual control, error-free workflow, and productivity. Learn About Stylizer >

GeckoFX Forum

Discuss GeckoFX, the Open-Source Gecko Control for .NET

You are not logged in.

How to run GeckoFX in a thread/block ads?

#1 January 26, 2010 1:11 PM

hasenbolle
Member
Registered: January 26, 2010
Posts: 2

How to run GeckoFX in a thread/block ads?

Hi,

i'm developing a WebBrowser plugin for a media application. The browser runs now fine in the application, but it has some performance problems (gui slowdowns etc.) This happens especially if there a some big flash ads or javascript effects.

My first idea was to run the webbrowser in a sperate thread, but how do i run the browser in a thread? I know how to run a specific method in a thread, but how to run the COMPLETE geckoFx browser in a thread?

The second idea was do block the flash ads and the image ads, like the AdBlock extension for Firefox does, but in a simple way. Of course i can check the whole website after the DocumentCompleted event is fired, for unwanted links, but that is not the way a adblocker should work. It should block the ads right when they try to load.

Hopefully someone has some ideas :D

Greetings from Germany
Chris

Offline

 

#2 January 26, 2010 11:45 PM

Cristian
Member
Registered: January 16, 2010
Posts: 17

Re: How to run GeckoFX in a thread/block ads?

You can't run geckos in different threads from your code. It does it itself internally.
The most you can do is invoke them from threads and wait their responses.

For the adblocker, I think you should subscribe to an event that will fire for each downloaded object in the page, not sure which event you have to capture. If so you could filter the ones you don't want gecko to download. This is how it works with the internet explorer control in .NET, this one should be similar.

Offline

 

#3 January 27, 2010 12:15 PM

hasenbolle
Member
Registered: January 26, 2010
Posts: 2

Re: How to run GeckoFX in a thread/block ads?

Thanks for your reply, Cristian.

I've called the constructor of gecko in a thread and call the Navigate method in a thread. Don't know if it's delusion or it's really faster than before.Whatever..

For the adblocking thing i've edited the "Navigation" event. Now it will be fired with every transmitted data.

Let's say the Navigation event gets fired when the image "http://www.google.de/intl/de_de/images/logo.gif" is transfered and i wan't to block this image. Now it would be good to have a GeckoElement of the html element with this particular url. Then i could easy set the html "style" attribute to "display: none;" for this element and the image is not displayed anymore.

Has someone an idea? I've tried various things with parsing the InnerHtml of the Document, but this was too slow, even for a normal windows application.

Last edited by hasenbolle (January 27, 2010 12:21 PM)

Offline

 

Board footer