延迟的KeyUp行动,如果用户键入(C#) [英] Delay KeyUp Action if User is Typing (C#)

查看:111
本文介绍了延迟的KeyUp行动,如果用户键入(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个当用户在搜索框中输入正被调用的函数。我想等待用户完成输入之前,我实际执行的功能。我知道如何轻松地与超时做到这一点在JavaScript中,但我将如何去在C#中做同样的事情?另外,我要多长时间等待之前,我假设用户完成输入? 100ms的?

I have a function that is being called when the user is typing in a search box. I want to wait for the user to finish typing before I actually execute the function. I know how to easily accomplish this in JavaScript with timeouts, but how would I go about doing the same thing in C#? Also, how long should I wait before I assume the user is done typing? 100ms?

推荐答案

设置定时器所需的延迟时间。启动的关键事件定时器。如果定时器车次停止计时器,并运行您的搜索。

Set a timer for the desired delay interval. Start the timer on the key up event. If the timer trips you stop the timer and run your search.

100ms的是的的一个很好的区间,尽管!这是约100wpm即使打字绝对是偶数。

100ms is NOT a good interval, though!! That's about 100wpm even if the typing is absolutely even.

这篇关于延迟的KeyUp行动,如果用户键入(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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