Solved

Background worker

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

943 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

17 Experts available now in Live!

Get 1:1 Help Now