开发者

WinForms - How to operate with a list of sites after loading in WebBrowser?

开发者 https://www.devze.com 2023-04-11 20:16 出处:网络
I have a list view with a list of sites to check. Checked sites should be loaded and operated after document is fully loaded one by one. That\'s what I do:

I have a list view with a list of sites to check. Checked sites should be loaded and operated after document is fully loaded one by one. That's what I do:

private void submitBtn_Click(object sender, EventArgs e)
    {
        int i = 0;
        foreach (ListViewItem item in sitesList.Items)
        {
            if (item.Checked) indices.Add(i++);
        }

        Thread thread = new Thread(new ThreadStart(submit));
        thread.Start();
    }

    private void submit()
    {
        foreach (int i in indices)
        {
            SiteInfo currentSite = sites[i];
            if (currentSite.AuthOn)
开发者_开发知识库            {
                inLoadingState = true;
                webBrowser.Navigate(currentSite.LoginPage);
                loginToSite(currentSite);

            }
        }
    }

Then I handle DocumentCompleted event of WebBrowser control. Currently, the program attempts to make login when the document is not yet loaded. Please, advise how it's better to make a thread to wait until the documents is loaded.

Thanks in advance!


Looks like you would want to do this on the OnDocumentCompleted event.

0

精彩评论

暂无评论...
验证码 换一张
取 消