c# - How to avoid that WPF ListBox updates block buttons? -


i have wpf window listbox, bound public observablecollection<string>, being updated thread (backgroudworker).

<listbox name="listbox"           itemssource="{binding mycollection}"           ... /> 

in same window have button click handler:

<button content="close"         click="button_logwindow_closebutton_click"         ... /> 

this handler not called when click button while listbox being updated. although works when background thread has finished , listbox not being updated more.

this looks me button click event being removed queue before it's handler can called. right?

do know how fix this?

it's hard without seeing code, gui thread busy updating listbox on every call observablecollection's add method mouse click event not handled.

if background thread using dispatcher.invoke or dispatcher.begininvoke add items observablecollection, can lower priority (to dispatcher.background, example) in order give click events chance handled.

you use observablecollection add range method raises inotifycollectionchanged.collectionchanged event once collection of items instead of each item. see this answer or microsoft's own bulkobservablecollection examples.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -