开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜