相关疑难解决方法(0)

使用Application.DoEvents()

可以Application.DoEvents()在C#中使用吗?

这个函数是否能够让GUI跟上应用程序的其余部分,就像VB6 DoEvents一样?

c# doevents winforms

263
推荐指数
6
解决办法
17万
查看次数

WebBrowser控件在一个新线程中

我有一个列表Uri,我想要"点击"为了达到这个目的,我试图为每个Uri创建一个新的Web浏览器控件.我为每个Uri创建一个新线程.我遇到的问题是文档在文档之前结束是完全加载的,所以我永远不会使用DocumentComplete事件.我怎么能克服这个?

var item = new ParameterizedThreadStart(ClicIt.Click); 
var thread = new Thread(item) {Name = "ClickThread"}; 
thread.Start(uriItem);

public static void Click(object o)
{
    var url = ((UriItem)o);
    Console.WriteLine(@"Clicking: " + url.Link);
    var clicker = new WebBrowser { ScriptErrorsSuppressed = true };
    clicker.DocumentCompleted += BrowseComplete;
    if (String.IsNullOrEmpty(url.Link)) return;
    if (url.Link.Equals("about:blank")) return;
    if (!url.Link.StartsWith("http://") && !url.Link.StartsWith("https://"))
        url.Link = "http://" + url.Link;
    clicker.Navigate(url.Link);
}
Run Code Online (Sandbox Code Playgroud)

c# browser multithreading

83
推荐指数
2
解决办法
8万
查看次数

Cancelling a pending task synchronously on the UI thread

Sometimes, once I have requested the cancellation of a pending task with CancellationTokenSource.Cancel, I need to make sure the task has properly reached the cancelled state, before I can continue. Most often I face this situation when the app is terminating and I want to cancel all pending task gracefully. However, it can also be a requirement of the UI workflow specification, when the new background process can only start if the current pending one has been fully …

.net c# multithreading task-parallel-library async-await

22
推荐指数
3
解决办法
5104
查看次数

C#WebBrowser控件 - 表单提交不使用InvokeMember("点击")

我正在使用自动测试脚本,并使用WebBrowser控件.我试图在用户接受服务条款时提交以下HTML并进行测试:

    <form action="http://post.dev.dealerconnextion/k/6hRbDTwn4xGVl2MHITQsBw/hrshq" method="post">
        <input name="StepCheck" value="U2FsdGVkX18zMTk5MzE5OUgFyFgD3V5yf5Rwbtfhf3gjdH4KSx4hqj4vkrw7K6e-" type="hidden">
        <button type="submit" name="continue" value="y">ACCEPT the terms of use</button>
        <button type="submit" name="continue" value="n">DECLINE the terms of use</button>
    </form>

    // Terms of Use Information

    <form action="http://post.dev.dealerconnextion/k/6hRbDTwn4xGVl2MHITQsBw/hrshq" method="post">
        <input name="StepCheck" value="U2FsdGVkX18zMTk5MzE5OUgFyFgD3V5yf5Rwbtfhf3gjdH4KSx4hqj4vkrw7K6e-" type="hidden">
        <button type="submit" name="continue" value="y">ACCEPT the terms of use</button>
        <button type="submit" name="continue" value="n">DECLINE the terms of use</button>
    </form>
Run Code Online (Sandbox Code Playgroud)

这是C#中的代码,但不提交表单.

            HtmlElementCollection el = webBrowser.Document.GetElementsByTagName("button");
            foreach (HtmlElement btn in el)
            {
                if (btn.InnerText == "ACCEPT the terms of use")
                {
                    btn.InvokeMember("Click");
                }
            }
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激.谢谢.

c# forms automation submit webbrowser-control

4
推荐指数
1
解决办法
1万
查看次数