IonicWind Software

Aurora Compiler => General Discussion => Topic started by: Parker on April 20, 2007, 01:22:39 PM

Title: Threading issues with CWebBrowser
Post by: Parker on April 20, 2007, 01:22:39 PM
This is in response to this topic. (http://www.ionicwind.com/forums/index.php/topic,1461.0.html) 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
Title: Re: Threading issues with CWebBrowser
Post by: sapero on April 20, 2007, 06:39:36 PM
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.
Title: Re: Threading issues with CWebBrowser
Post by: Parker on April 20, 2007, 11:54:36 PM
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)
Title: Re: Threading issues with CWebBrowser
Post by: Rock Ridge Farm (Larry) on April 22, 2007, 05:25:58 AM
Version 7 seems to have issues with lots of stuff.
Title: Re: Threading issues with CWebBrowser
Post by: J B Wood (Zumwalt) on April 23, 2007, 08:17:42 AM
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.
Title: Re: Threading issues with CWebBrowser
Post by: Rock Ridge Farm (Larry) on April 23, 2007, 08:43:54 AM
I have found several web apps that act strange with IE7.
Title: Re: Threading issues with CWebBrowser
Post by: Parker on April 24, 2007, 03:57:19 PM
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.