Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7877209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:18:08+00:00 2026-06-03T03:18:08+00:00

I am venturing into WPF – first time in (VB).NET – and trying to

  • 0

I am venturing into WPF – first time in (VB).NET – and trying to re-create a project I started in MS Access VBA. It basically scrapes a series of pages within a web application. As you may have surmised I am having trouble with the LoadCompleted event.

I have searched and found some information on it, but the “flow” of the code only lends itself to waiting for one page to load. For example:

http://social.msdn.microsoft.com/Forums/nn-NO/wpf/thread/52c1bc55-dd41-468c-8759-a42726635d4b

All of the code execution is run in the DocumentLoaded event which works fine when you just need to navigate to one page and execute code. But I need to perform a series of these cycles for my application.

How can I reliably wait for the document to fully load while still keeping the code execution in the same Sub AND not locking the UI thread?

Here’s a basic idea of what I’m trying to do.

  1. Navigate to page
  2. Wait for page to fully load
  3. do stuff
  4. Navigate to page
  5. Rinse, Repeat

P.S – .NET is very new to me so please don’t give my brain a stack overflow 😉

Thanks,
Brian

-## EDIT ##-

This is what I use to do in VBA. This is exactly what I’m trying to do, just in the “.NET” way and without blocking the UI Thread:

Dim oIE = New SHDocVw.InternetExplorer

        With oIE
            .Navigate(strURL)
            .Visible = False


           ' loop until the page finishes loading
           Do While oIE.Busy : Loop
           Do While oIE.ReadyState <> 4 : Loop

           'Code goes here to read DOM, get fields and click a button (logging in to site)
           'My code execution is done and now I'm ready to go to the next page and read the DOM

           .Navigate(strURL)

        End With

.
.
.
.

That’s it. Repeat for n times. my interactions with each DOM are significantly different.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:18:09+00:00Added an answer on June 3, 2026 at 3:18 am

    I would just call Navigate again at the end of the LoadCompleted handler. Then, I guess, use a window-scoped variable to keep track of your target URLs.

    List<string> _urls;
    int _i = 0;
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        _urls = new List<string>() { url1, url2, url3 };    // URLs to navigate
        webBrowser1.LoadCompleted += webBrowser1_LoadCompleted;
        webBrowser1.Navigate(_urls[_i]);
    }
    void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
    {
        // do stuff
    
        i++;
        var nextUrl = _urls[i];
        webBrowser1.Navigate(nextUrl);
    }
    

    EDIT

    Maybe something like this would be more suitable. After each cycle, you can set up the next URL as well as its handler.

    class NavIteration
    {
        public string Url { get; set; }
        public delegate void HandleResult(object sender, NavigationEventArgs e);
        public HandleResult ResultHandler { get; set; }
    }
    
    NavIteration CurrentIteration;
    
    void setNextIteration()
    {
        CurrentIteration = null;
        CurrentIteration = new NavIteration() { 
            Url = someurl, 
            ResultHandler = (sender, e) => {
                // handle
            }
        };
    }
    
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        webBrowser1.LoadCompleted += webBrowser1_LoadCompleted;
        setNextIteration();
        webBrowser1.Navigate();
    }
    
    void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
    {
        CurrentIteration.ResultHandler(sender, e);
        setNextIteration();
        webBrowser1.Navigate(CurrentIteration.Url);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some background.... We're venturing into Azure for the first time and are trying to
I'm venturing into making my VB.NET application a little better to use by making
I'm venturing out of the world of .NET and into the world of open-source.
In venturing into Ruby , I started toying with things like the way Ruby
I have recently started venturing into some HP webOS development and I am wondering
I am venturing into the world of setting up cronjobs and trying to learn
I'm venturing into the world of asp.net mvc. I have not yet understood whether
If you had a differential of either venturing into Delphi land or Qt land
I'm venturing into the world of C++ and Linux, and am having problems linking
I am a PHP/MySQL developer, slowly venturing into the realm of C#/SQL Server and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.