title: c# Get URL of the new page after invoking click in Web Browser
body: <p>I have to navigate through some pages with an Application Console in C#, I have a known URL as a starting page, but other URLs are not known, I reach them by clicking on buttons in the starting page.<br>
  This is the code of the button I need to click on the page:</p>
  
  <pre><code>&lt;input name="ctl00$ContentPlaceHolder1$btn_invia" type="button" id="myId" onclick="ReDirect();" class="myClass" value="BUTTON TEXT" /&gt;
  </code></pre>
  
  <p>I tried this code to navigate to the start page, and it works:</p>
  
  <pre><code>class Program
  {
    private static WebBrowser wb1 = new WebBrowser();
  
    [STAThread]
    static void Main(string[] args)
    {
      runBrowserThread(new Uri("http://www.myUrl.com"));
    }
  
    private static void runBrowserThread(Uri url)
    {
      var th = new Thread(() =&gt; {
          var br = new WebBrowser();
          br.DocumentCompleted += Br_DocumentCompleted; ;
          br.Navigate(url);
          Application.Run();
      });
      th.SetApartmentState(ApartmentState.STA);
      th.Start();
    }
  
    private static void Br_DocumentCompleted(object sender, 
    WebBrowserDocumentCompletedEventArgs e)
    {
      //Retrieve string content of document
      var document = ((WebBrowser)sender).Document;
      var documentAsIHtmlDocument3 = 
      (mshtml.IHTMLDocument3)document.DomDocument;
      var content = documentAsIHtmlDocument3.documentElement.innerHTML;
  
      //Parse content with html agility pack or whatever
  
      //Click on button
      wb1.Document.GetElementById("myId").InvokeMember("click");
  
      Application.ExitThread();
    }
  }
  </code></pre>
  
  <p>When I click on the button, it loads a new page.
  But when I call <code>.InvokeMember("click");</code> it freezes, how can I make the WebBrowser wb1 go to the new page?</p>