Q:

C# Webbrowser navigating links in order

I'm trying to teach myself C# and to start I'm trying to convert a program I originally wrote in Autoit. 
I'm using a Windows Application Form and the program is suppose to take one or two links as input. Navigate to those to pages, grab some links from a table, then visit each of those pages to grab some content.
If only one link is entered it seems to go to that page and grab the links from a table like it is suppose to. If two links are entered it seems to only grab the links from the second table.
So if two links are passed this method 
    private void getPageURLList(string site1, string site2)
    {
        getPageURLList(site1);
        getPageURLList(site2);           
    }

Calls the same method that gets called when there is only one link
    private void getPageURLList(string site)
    {
        webBrowser.DocumentCompleted += createList;
        webBrowser.Navigate(site);
    }

I'm pretty sure the issue is "Navigate" is getting called a second time before createList even starts the first time. 
The reason I am using WebBrowser is because these pages use Javascript to sort the links in the table so HTTPRequests and the HTMLAgilityPack don't seem to be able to grab those links.
So I guess my question is: How can I keep my WebBrowser from navigating to a new page until after I finish what I'm doing on the current page?

A:

You have to make a bool variable to know when the first proccess has completed. And then start the other. Application.DoEvents() will help you.
Note that all this events run in the main thread.

