- Joined
- Dec 1, 2007
- Messages
- 38,987
- Likes received
- 2,910
- Thanks received
- 678
- Location
- My house
DP did have a point, until you clarified. It hurts to say it, mind.Tosser.![]()
DP did have a point, until you clarified. It hurts to say it, mind.Tosser.![]()
Can BackgroundWorker update any or all GUI elements from within its own thread? It seems that it can report progress via callbacks, but can it change other elements like text on GUI?
The background worker cannot access the GUI thread directly, but can access the controls using the Threading.Dispatcher

You are confusing me with somone WGAS.

Since when is the proper design the easiest one? It's easier to have all class members public... though being able to do GUI stuff cross-thread would be nice, are there design issues such as performance to think about?How is it easier than...
though being able to do GUI stuff cross-thread would be nice, are there design issues such as performance to think about?

To me, a polling loop updating GUI from stored state is a horrible design, it's just plain bad. However, it's not that uncommon so it depends where you draw the line between 'perfect design' (virtually impossible in most software) and 'whatever I can get in faster' (which leads to crappy code). Everyone has their own place on that spectrum.Personally I think simple timer callback that will update GUI that is necessary is much easier and faster (coding time and performance wise) than using DimPrawn's approach, though I admit my way might have negative effect on amount of money earned from the same coding task![]()
To me, a polling loop updating GUI from stored state is a horrible design, it's just plain bad. However, it's not that uncommon so it depends where you draw the line between 'perfect design' (virtually impossible in most software) and 'whatever I can get in faster' (which leads to crappy code). Everyone has their own place on that spectrum.
We are not talking about here games performance - it's bonkers that non-GUI thread can't update text label with current value, if they are so worked out about it then Microsoft should have implemented internal locking to do the job.
The whole WinForms implementation in .NET is poor - it was clearly done by very different people (quality wise) than CLR team who were excellent.
Personally I think simple timer callback that will update GUI that is necessary is much easier and faster (coding time and performance wise) than using DimPrawn's approach, though I admit my way might have negative effect on amount of money earned from the same coding task![]()
