Martin Brabec
Martin Brabec

Reputation: 3860

Control not fires DoubleClick event because of code behind another event

I did not find the answer anywhere, so I'll make new question. I have datagrid, where is some code after SelectionChanged event. And some code on DoubleClick(tried MouseDoubleClick, CellDoubleClick and DoubleClick). On fast PC there is no problem, but on my windows 8 tablet with Intel Atom, where is the app slower, is not fired DoubleClick because of SelectionChange.

If I comment code on SelectionChange, then DoubleClick is fired. But when I leave the code, it seems like it is so slow, that it did not recognize DoubleClick. I have to click realy fast (7-8 times) to fire it.

I thought there is some kind of queue. So that DoubleClick should be fired after SelectionChange at least.

I can't wait after SelectionChange is fired to see if it is not a DoubleClick. Then will look the app slow even on fast pc.

How can be this event lost?

Upvotes: 0

Views: 701

Answers (2)

szelpe
szelpe

Reputation: 336

You shouldn't do any long calculations in an event handler. I suggest starting a new thread (or borrow one from the threadpool, or start a new task), and do the longer running code on a background thread.

Upvotes: 1

Guvante
Guvante

Reputation: 19221

It sounds like you may be doing work on the main thread, try using a different thread to do your processing, freeing up your UI thread to receive the double click.

You will need to do some synchronizing, but it should relieve the race condition if done correctly.

Upvotes: 1

Related Questions