时间事件被发送了? [英] Time event was sent?

查看:169
本文介绍了时间事件被发送了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JavaFx中,有没有可靠的方法来了解事件发布的时间?

In JavaFx, is there any reliable way to know at what time an event was posted ?

由于这个问题对于stackoverflow来说太短了,我详细说明了什么。在我认为是javafx的异步事件系统中,事件会在队列中发布,然后在后期处理。发布和处理之间的时间是未知的,尽管估计它很小。然而,无法保证这一次确实很小。因此,我真的想知道是否可以知道发布活动的时间。例如:当用户实际点击按钮时(而不是程序看到它时)。

And since this question is too short for stackoverflow, I elaborate somwhat. In asychronous event systems, which I believe javafx is, events get posted on a queue and then at a later stage handled. The time between posting and handling is unknown, allthough it is estimated to be small. Nevertheless, there are no guarantees that this time is indeed small. Therefor I would really like to know whether it is possible to know the time of posting the event. E.g: when the user actually clicked the button (as opposed to when the program looks at it).

推荐答案

简答:否。

根据 JavaFX架构它使用本机事件队列来捕获和批处理所有事件。通过捕获它被理解为在那个时刻生成事件(用户点击按钮)。考虑到批处理,我们已经丢失了有关事件生成时间的信息(除非JavaFX在内部保留该信息,您可以检查 com.sun.javafx 包的较低级别细节)。每1/60秒就有一个预定的脉冲事件。在脉冲事件期间,所有其他JavaFX事件(如MouseEvent等)都是通过普通的JavaFX事件调度机制触发的。此时,您的应用程序将从JavaFX收到发生事件的通知。因此,在理想的世界中,发布事件的时间与处理事件的时间之间的差异应该是< 0.0166(6)秒。

According to JavaFX Architecture it uses the native event queue for capturing and batching all the events. By capturing it is understood that at that moment in time the event was generated (the user clicked the button). Taking batching into account we have already lost the information about the time the event was generated (unless JavaFX internally keeps that information, you can inspect com.sun.javafx packages for lower level details). Every 1/60th of a second there is a scheduled pulse event. During the pulse event all other JavaFX events like MouseEvent, etc. are fired via the normal JavaFX event dispatching mechanism. It is at this point that your application will receive a notification from JavaFX that an event has occurred. So in an ideal world the difference between the time an event was posted and the time it was handled should be < 0.0166(6) seconds.

这篇关于时间事件被发送了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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