0

in my application there are a lot of textboxes that bind to some properties that changes by network messages, so the text of textboxes are change very rapidly so the ui freezes. for solving this problem i want to use the multi threading but only main-thread access to the controls so How do i bind the property of controls in another thread to prevent main-thread overloading that cause ui freazing???

robert
  • 21
  • 2
  • Have you done any research on how to do this? – ProgrammingLlama Apr 02 '20 at 02:35
  • yes but everywhere said that only main thread had access to the UI, I will be glad if you have any reference that can solve my problem. – robert Apr 02 '20 at 02:55
  • Did you try searching for "update ui from another thread winforms"? Is there a reason why the [first result](https://stackoverflow.com/questions/661561/how-do-i-update-the-gui-from-another-thread) doesn't work in your case? – ProgrammingLlama Apr 02 '20 at 03:01
  • See marked duplicate for how to run code in a thread other than the UI thread. Note that even using those kinds of techniques, you need to make sure you don't try to update the UI too frequently. Otherwise the UI thread will get overwhelmed, not be able to keep up, and still effectively "freeze" (it will eventually respond, but at a very slow rate). – Peter Duniho Apr 02 '20 at 03:21
  • The answer is: you can't. No other thread except the UI thread can touch the controls, so there is no solution to the problem of how to make more UI changes than the UI thread can handle. The solution to your problem is to reduce the UI changes, and to do so you must throttle the network messages. One way to do it is by using [Reactive Extensions](https://www.nuget.org/packages/System.Reactive/) and the method [`Throttle`](http://reactivex.io/documentation/operators/debounce.html). There may be simpler solutions though. – Theodor Zoulias Apr 02 '20 at 12:00

0 Answers0