C#,引入DragOver延迟
在我的应用程序中,我捕获 DragOver 事件,然后执行操作。我想在执行操作之前等待半秒,如果拖动操作已结束,则在延迟之后不应执行该操作。
我能想到的实现此功能的唯一方法是这样的:
Function DragOver Event
If TimerTimeReached Then
PerformDragAction
Else If Not TimerStarted
StartTimer
End
End Function
Function DragLeave Event
If TimerStarted
StopTimer
End
End Function
是否有更好的方法来执行此操作?
In my application I catch a DragOver event and then perform an action. I'd like to wait for half a second before performing the action, the action should not be performed after that delay if the drag operation has ended.
The only way I could think of to implement this feature is something like this:
Function DragOver Event
If TimerTimeReached Then
PerformDragAction
Else If Not TimerStarted
StartTimer
End
End Function
Function DragLeave Event
If TimerStarted
StopTimer
End
End Function
Is there a better way to perform this operation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来没问题,但是DragOver 事件会发生多次吗?
我认为 PerformDragAction 应该移至 Timer 事件处理程序。
It looks OK, but does the DragOver event happen multiple times?
I think the PerformDragAction should move to a Timer event handler.