C# WebBrowserDocumentCompletedEventHandler inside of foreach loop
<p>How do I cause the documentCompleted event to actually wait for completion inside a foreach loop.</p>

<p>The StaticStringclass.URLList is a list of websites, so just like www.google.com,www.aol.com.</p>

<p>Any advise is awesome.</p>

<p>StaticStringClass.holderList = new Queue();</p>

<pre><code>        StaticStringClass.QueryHolder = new List&lt;string&gt;();
        StaticStringClass.CrawledBit = new List&lt;string&gt;();
        StaticStringClass.URLList = new List&lt;string&gt;();
        string startingHTML = "http://www.decodethis.com/Default.aspx?tabid=65&amp;vin=";
        foreach (string listCar in StaticStringClass.CarIDs)
        {
            StaticStringClass.CarLister = listCar;
            string realModel = string.Empty;
            string realTrim = string.Empty;
            string htmlHold = string.Empty;
            string[] splitListCar = listCar.Split('|');
            string realvin = splitListCar[1];
            StaticStringClass.URLList.Add(startingHTML + realvin);
        }
        ProcessSites();
}
private Queue&lt;string&gt; downloadQueue = new Queue&lt;string&gt;();

    public void ProcessSites()
    {

        foreach (string siteList in StaticStringClass.URLList)
            downloadQueue.Enqueue(siteList);

        webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);

        if (downloadQueue.Count &gt; 0)
        {
            string nextSite = downloadQueue.Dequeue();
            webBrowser1.Navigate(nextSite);
        }





        //foreach (string siteList in StaticStringClass.URLList)
        //{

        //    webBrowser1.Navigate(siteList);
        //    webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
        //}


    }
</code></pre>
