Solved

Background worker

Posted on 2014-03-13
5
400 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now