coddicat / DebounceThrottle

C# Debounce and Throttle dispatchers
MIT License
48 stars 15 forks source link

Executing on the wrong thread in WPF #2

Closed Montago closed 1 year ago

Montago commented 3 years ago

I used this lib to debounce inputs from the user.

the action is executed in a different thread than UI - which means that DependencyProperties are inaccessible.

I had to wrap the inner content of the Action in a different Dispatcher:

debouncer.Debounce(() => { Application.Current.Dispatcher.BeginInvoke(new Action(() => { UpdateCarModels(); })); });

coddicat commented 1 year ago

I updated the package, plus yes Application.Current.Dispatcher.BeginInvoke you have to do in your case