March 28, 2024, 11:30:38 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Threading issues with CWebBrowser

Started by Parker, April 20, 2007, 01:22:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Parker

This is in response to this topic. The program is fairly complex, but you can reproduce the problem very simply. In the Web browser example program, find a Navigate() call and change that to create a new thread that tries to make the browser navigate to that page. I don't have a computer with Aurora where I am right now, but this is basically what it would look like:
import unsigned int CreateThread( void *lpThreadAttributes, unsigned int dwStackSize, unsigned int lpStartAddress, void *lpParameter, unsigned int dwCreationFlags, unsigned int *lpThreadId );

sub homepage( MainWindow *window )
{
    window->browser.Navigate( "http://www.google.com/" );
}

MainWindow::GoHome( )
{
    int unused;
    CreateThread( 0, 0, &homepage, this, unused );
}


You will probably get a notice saying "Internet Explorer cannot find the website 'http://www.google.com/'";. This is a problem because my client and server are running in separate threads (it wouldn't work if they weren't), but they need to be able to send the browser to certain URLs.

So my question is this: Is it possible either to make the browser accept this, or to communicate between threads and have the browser's thread do the Navigate()'ing?

Any help is appreciated.
Parker

sapero

April 20, 2007, 06:39:36 PM #1 Last Edit: April 20, 2007, 06:41:36 PM by sapero
It works ok here, with modified browser_test.src example.
Maybe you don't know, but IWebBrowser2::Navigate() internally creates a background thread to complete your request.

Apropos redirecting thread from method to function. This snippet creates a thread directly in a method:
MyBrowser::homepage() // derieved from CWebBrowser
{
    Navigate( "http://www.google.com/" );
}

handle = CreateThread( 0, 0, &MyBrowser@homepage, this, 0, unused);

Note that CreateThread takes 6 parameters.

Parker

Hmm :(

Modifying the browser_demo.src file doesn't work for me. Is it possibly a problem with the version of IE I have? (Version 7.0.5730.11)

Rock Ridge Farm (Larry)

Version 7 seems to have issues with lots of stuff.

J B Wood (Zumwalt)

IE 7 introduced a new security layer.
This new layer blocks all but the highest signed objects from Microsoft.
Look through your default securities in IE7 and tweak them, also, there is no guarantee that you will get it to work since M$ is on a lockdown path.
Meaning that if its not M$ then most likely, its going to get blocked through there new security model.
One of there recent patches even blocks there own website, of course they patched it again the same day, but it said that the website contained unauthorized content and wouldn't load. Very few got that patch, but it was funny as hell.

Rock Ridge Farm (Larry)

I have found several web apps that act strange with IE7.

Parker

That adds an extra layer of complication to my code, unfortunately. Just for future reference if someone has the same problem, here is how I plan to solve it:
- Make a global queue of instructions
- Use multithreading APIs to make sure only one thread is using the queue at a time
- Start a timer with a very short interval in the GUI thread to check the queue
- If there is an instruction, interpret it and act on it

If that doesn't work, I guess I'm out of ideas :-\

Thanks for the help everyone.