2

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.

3
  • 4
    It seems plausible to me that you would continue reacting to all the user's clicks because in spite of his craziness they might have wanted to actually do something. Therefore, "stupid is as stupid does" seems to be a fair enough UI response...
    – Reddog
    Commented Sep 28, 2011 at 19:09
  • 7
    It sounds like the underlying issue is that the event handlers are taking too long to complete. Any logic that blocks the UI's message handling for more than a few milliseconds should probably end up delegated to a background thread.
    – Dan Bryant
    Commented Sep 28, 2011 at 19:15
  • I'm 100% with Dan. Sounds like the UI is jacked on it's response times. Fix that. If the UI is actually very responsive then have a talk with whoever established that use case and criteria.
    – NotMe
    Commented Sep 28, 2011 at 19:23

2 Answers 2

0

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?

0

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.