奇怪的System.Threading.Thread.Sleep(3000)小故障? [英] Strange System.Threading.Thread.Sleep(3000) Glitch?

查看:108
本文介绍了奇怪的System.Threading.Thread.Sleep(3000)小故障?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HtmlElement sendraid3 = wb.Document.All["btn_ok"];
            sendraid3.InvokeMember("click");
            
            System.Threading.Thread.Sleep(3000);



我想在点击后等待,但是应用程序在此之前暂停.为什么?



I want to wait after the click, however the application pauses before. why is that?

推荐答案

如果看起来并不奇怪;当然这不是睡眠故障.

如果我没有记错(请在问题注释中查看我的问题),请单击进入UI消息队列,它立即发生,但是在处理之前,您将UI线程置于等待状态(从不)顺便说一下).仅当线程由于睡眠时间到期而被唤醒时,所有处理都被冻结并恢复.

—SA
If does not look strange; and of course this is not a sleep glitch.

If I''m not much mistaken (please see my question in the comment to your question), click goes to the UI message queue, and it happens immediately, but before it is processed you put the UI thread in the wait state (never do it, by the way). All processing is frozen and resumed only when the thread is awaken by the expiration of sleeping time.

—SA


这篇关于奇怪的System.Threading.Thread.Sleep(3000)小故障?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆