I read data through WebSocket, the data gets into the project infrastructure and is processed, then added to the collection. During operation, multithreading is used, but as it is necessary to display these collections on the form, I display them via DataGridView.DataSource = List <...>. The data is not added during processing when the form is open, so the collection is blocked from being added and is waiting to be re-bound. Tell me how to call a specific method, for example, Add - add data to the collection in the UI stream?

  • myWindow.Invoke(new Action(() =>{ /*......*/ })); ? - tym32167
  • Use BindingList or ObservableCollection instead of a simple List . Items within the collection must have the INotifyPropertyChanged interface INotifyPropertyChanged . - Alexander Petrov
  • Um, I spent some time analyzing the problem. It turns out that the ListBox updated dynamically from another thread (linked to a BindingList and using Invoke ). But with a DataGridView the situation is bad. Probably, it is in its internal structure. - Alexander Petrov
  • The @ tym32167 method is deep in the project and there is no way to call it that way, your past advice with proxying the form doesn't really work either - Unnamed
  • @Alexander Petrov with ListBox is the same situation, until I reload the form with the element, the data will not be added ... as if access to the collection is blocked but it is updated BUT data is not added when it is used. So it seems to me that I need a transfer to UI - Unnamed

0