简体   繁体   中英

'webbrowser.documentCompleted += procedure' translation from c# to vb.net

Usually when i need to convert code from c# to vb.net i use this link http://converter.telerik.com/ but looking to an old answer ( WebBrowser Control in a new thread )

i found this line that i don't understand, and that the converter don't translate:

br.DocumentCompleted += browser_DocumentCompleted;

private void runBrowserThread(Uri url) {
var th = new Thread(() => {
    var br = new WebBrowser();
    br.DocumentCompleted += browser_DocumentCompleted;
    br.Navigate(url);
    Application.Run();
});
th.SetApartmentState(ApartmentState.STA);
th.Start();
}

void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
    var br = sender as WebBrowser;
    if (br.Url == e.Url) {
        Console.WriteLine("Natigated to {0}", e.Url);
        Application.ExitThread();   // Stops the thread
    }
}

Anyone know the translation?

Thanks

That line is adding an event handler for WebBrowser.DocumentCompleted event, pointing to the browser_DocumentCompleted method.

This is the translation: AddHandler br.DocumentCompleted, AddressOf browser_DocumentCompleted

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM