简体   繁体   中英

How to efficiently react to touch events in Windows RT

This might be a dumb question but I'm not familiar with XAML.

I'm implementing a RTP-MIDI client Library for Windows Store Apps and would like to investigate and troubleshoot potential latency and performance problems.

I've written a quick dummy application with a couple of buttons to send MIDI events to an musical instrument over the network using my Library. In that scenario, I find that my Library is able to process a single basic MIDI event in under 10ms over the network, but I find that the delay between the time I press a button on the UI and the time where my Library is instructed to send an event is very high.

Ideally, I would like to react to a "touch pressed" event and instantly send a MIDI event as well as a "touch released" event and instantly send the corresponding MIDI event.

I could not find such events on the regular button controls. Ideally, I would like to achieve the highest performance possible from the UI, even with a single button, in order to eliminate this source of problems in my performance assessment.

Is there a way I could react to the screen being touched "in real time" like a game, for instance?

The most basic access to various pointer events (such as tapping, clicking) are available through a series of lower level events, with these being directly related to your question:

  1. PointerPressed
  2. PointerReleased

PointerPressed should be the equivalent of MouseDown for example in a traditional application as it fires early, and before any translation into a higher level event (such as Click ) has occurred.

The PointerReleased would be the equivalent of MouseUp . If you're relying on the PointerReleased event, you'll want to take note of the fact that the event isn't necessarily fired as a pair with the PointerPressed event, as there are a number of conditions where it may not fire. The documentation has the details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM