开发者

Best practice to limit event queue

开发者 https://www.devze.com 2023-04-08 04:58 出处:网络
I am looking for advice and help regarding a specific use case of an application. Here\'s the use case:

I am looking for advice and help regarding a specific use case of an application. Here's the use case:

A user our our WPF application goes crazy and starts clicking all over, triggering a number 开发者_运维技巧of events before the first (or previous) event(s) have to finish.

Currently, WPF queues any and all clicks and queues them for sequential execution. Ideally we would like to queue up to 3 events and drop and disregard any and all clicks (user interactions) after the first 3.

What would be the best approach to solving this issue, what is the best practice for this use case. Any documentation, code and/or help would be much appreciated.


Since this really is a windows issue and not specifically a WPF issue, the only thing I can think of is hooking the message queue and discarding clicks within a certain time unless you write specific handlers into each control. The other option is to write the application such that feedback is provided to the user during an operation and input is disabled.

What does WPF use to capture mouse and keyboard input?


If you'd use MVVM all UI actions are bound to ViewModel commands or properties. In the ViewModel you'd have full control over how many and how frequently you want to process what comes from the UI. It will probably involve some sort of producer consumer queue.

Also if your user actions block the UI, you need to process them outside the UI thread as much as possible.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号