Can you tell what is causing your delay?
If there is something slow in your Click
event, you may want to either use a seperate Thread
to execute the code. Within the new thread, if you have code that must be executed on the UI Thread, use Dispatcher.BeginInvoke
to queue it up to be executed when the UI has processing time. To keep the UI responsive, you need to keep any heavy code off the main (UI) thread.
If your virtual keyboard is local to a certain Window
, depending on the complexity of what you're doing, you can take an approach I've used in the past where you just manually fill in keyboard characters into the TextBox
that has focus.
Disclaimer: I wrote that code over 2 years ago and hate it as a result. While I'd normally pretend it didn't exist, it may help you out. I've made it better since then, but the concept itself had no performance issues on slower machines. I'd quote Jeff Atwood's blog about the code you hate most is your own, but, well...
Edit: Since you still have issues even with Click
empty, you may want to look at other potential hold-ups. Is the user's CPU maxed out at 100% from something? Either too heavy animations, or another potential event? Most UI delays are usually a result of either a maxed out CPU or an event taking too long on the UI's thread.
One possibility is if your Window
has AllowsTransparency="True"
, much of the workload that would normally go to the graphics card will now be rendered in software, and can have heavy performance penalties. Past that, you can take a look at this Microsoft article on Optimizing WPF Application Performance for some general tips which could speed up your processing.
I would suggest anyone developing in XAML read that last article. The difference in performance between such little details such as using TextBlock
vs. Label
, or implementing DependencyProperty
's vs. INotifyPropertyChanged
, can really add up, and the fact that they do benchmarking against each really shows the importance of proper design.