Solved

Background worker

Posted on 2014-03-13
5
456 Views
Last Modified: 2014-03-14
Hi Experts,

I have a Winform with a tab control on it. In one of the tab pages I have a button and a webrowser. When I click the button the webbrowser navigates to the required url. I use a background worker to navigate to the webpage so that I can select and use another tab page while the navigation is taking place. The problem is that the UI locks up during the navigation event and does not allow me to select another tab page until the navigation has completed. What am I doing wrong?

Public Class Form1

    Private Sub ButtonNavigate_Click(sender As System.Object, e As System.EventArgs) Handles ButtonNavigate.Click

        BackgroundWorkerBrowser.RunWorkerAsync()

    End Sub

    Private Sub BackgroundWorkerBrowser_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorkerBrowser.DoWork

        WebBrowser1.Navigate("http://www.betexplorer.com/next/soccer/")

    End Sub

End Class

Open in new window

0
Comment
Question by:DColin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Ammar Gaffar
ID: 39927224
Hi DColin,

The page you are trying to load contains scripts errors, try to load another page like www.microsoft.com it will work normally.

I used you scenario, even without using any background worker and it worked very smooth with url www.microsoft.com 

Good Luck
0
 

Author Comment

by:DColin
ID: 39927248
Ammar Gaffar,

I do not want to load microsoft.com I want to load the website from my question.
0
 
LVL 12

Expert Comment

by:Ammar Gaffar
ID: 39927453
Dear DColin,

You can set the WebBrowser's property ScriptErrorsSuppressed to True,  it will let you to navigate in your form's control.

Good Luck
0
 

Author Comment

by:DColin
ID: 39927517
Ammar Gaffar,

I have set ScriptErrorsSuppressed to True and no difference. I access this page using Firefox, Chrome and IE8 and do not get script errors reported. How do you know it has script errors?

If the page has loading errors why should this cause the webbrowser thread to lock the UI thread?
0
 
LVL 12

Accepted Solution

by:
Ammar Gaffar earned 500 total points
ID: 39927568
Dear,
Did you try to load different page e.g www.microsoft.com ? When I took microsoft as an example I just need to confirm is it from the web page itself or the browser or from your code.

Web Browser control is based on IE only, so even if the page is loaded well in other browsers that will not help much.

Anyway, I am using IE 11 and when I used your code script error dialog is appeared, and I did cross check in FireFox using Web Developer add-on and here below the error description:

Timestamp: 3/14/2014 12:04:17 AM
Error: A promise chain failed to handle a rejection.

Date: Fri Mar 14 2014 00:04:06 GMT+0400 (Arabian Standard Time)
Full Message: Win error 183 during operation makeDir (Cannot create a file when that file already exists.
)
Source Code:
0


I do believe that your code is fine, and to confirm it use another url and check!

Good Luck
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question