Solved

Background worker

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

623 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