Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-UI thread, UI access

It is well-known that you cannot update the UI from any other thread other than the UI thread.

However, I just discovered some code, that gets a value of a listview virtualsize, from a non-UI thread without Exception.

So really my question is: what interaction can you have with the UI from a non-UI thread?

Thank you Theo

like image 347
Theofanis Pantelides Avatar asked Jul 24 '26 11:07

Theofanis Pantelides


1 Answers

Because it works without throwing an exception, does not mean you should do this.

The problem is that besides the Invoke requirement for methods that update the UI, these controls also do not support multi threading. That means that when the UI thread updates the data while you are retrieving it, you do get corrupt data.

like image 68
Pieter van Ginkel Avatar answered Jul 27 '26 03:07

Pieter van Ginkel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!