Originally posted by Shimano105
View Post
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Reply to: WPF Dispatcher
Collapse
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
- You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
- You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
- If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "WPF Dispatcher"
Collapse
-
From what I've seen regarding WPF the idea is to use the Model-View-ViewModel pattern and rely on data binding to update your GUI rather than updating it imperatively.
-
I suspect this tulip is still part of Win32 API, though I've never programmed it deep enough to be sure.Originally posted by Shimano105 View PostI only recently had the pleasure of this 'updating the GUI on differnet threads' bollox on an old winforms app. I thought that WPF would have solved this. Huh.
The whole GUI part of .NET is very poorly done. Good thing I don't have to use it much...
Leave a comment:
-
So this tulip is still a part of windows development in .NET?
I only recently had the pleasure of this 'updating the GUI on differnet threads' bollox on an old winforms app. I thought that WPF would have solved this. Huh.
I'll stick with ASP.NET then as this seems to have it abstracted away
Leave a comment:
-
It's not great, but I'd say much more fundamentally bad design of Windows GUI is its inability (in .NET) to get updated easily from threads other than main GUI thread.Originally posted by d000hg View PostI am not talking about it being difficult. I am saying a polling loop to update GUI from state (which is what using a timer achieves) is fundamentally a bad design in a Windows GUI application.
Leave a comment:
-
I am not talking about it being difficult. I am saying a polling loop to update GUI from state (which is what using a timer achieves) is fundamentally a bad design in a Windows GUI application.Originally posted by AtW View PostEh? Timer calls function that updates GUI elements, it can call actual class functions who know how to do it, only this happens on the GUI thread so no issues. Also function can be smart enough to only update visible components or changed values, trivial to do.
Leave a comment:
-
I dunno but I expect updating that label via the dispatcher or the backgroundworker would have been a lot simpler than spending the time creating that post. Possibly the most frustrating thing about programming at all is the amount of time some people will spend discussing why they shouldn't change 5 lines of their code as opposed to just doing it!Originally posted by suityou01 View PostI had just not realised what a c<nt WPF is when it comes to handling this tulip. I fully agree with ATW that each object should have a better implementation of cross thread chat for something as simple as updating a label caption FFS.
Praps
MyBstardLabel.Caption.UpdateByDispatcher(Value)
I dunno but would cut out a lot of the ball ache.
Leave a comment:
-
Oh go with WPF, it's wicked man.Originally posted by AtW View PostEh? Timer calls function that updates GUI elements, it can call actual class functions who know how to do it, only this happens on the GUI thread so no issues. Also function can be smart enough to only update visible components or changed values, trivial to do.
I've written games long time ago and one lesson I learnt early on was that redrawing whole lot is faster in reality than trying to be too smart - these days even low end computers have powerful graphics accelerators and Windows is smart enough to avoid updating invisible elements.
It should have been possible to have multi-threaded access to GUI - the fact that Microsoft still did not manage to implement it in a clean new project (.NET) is pathetic, but then again the whole of WinForms was poorly designed and WPF seems rather too heavy.
I am actually planing to do more GUI work soon, and still can't decide whether I should stick with rather pathetic WinForms or take huge risk with WPF.
Leave a comment:
-
Eh? Timer calls function that updates GUI elements, it can call actual class functions who know how to do it, only this happens on the GUI thread so no issues. Also function can be smart enough to only update visible components or changed values, trivial to do.Originally posted by d000hg View PostYes that part's fine, it's the whole "run a loop to see what's changed"
I've written games long time ago and one lesson I learnt early on was that redrawing whole lot is faster in reality than trying to be too smart - these days even low end computers have powerful graphics accelerators and Windows is smart enough to avoid updating invisible elements.
It should have been possible to have multi-threaded access to GUI - the fact that Microsoft still did not manage to implement it in a clean new project (.NET) is pathetic, but then again the whole of WinForms was poorly designed and WPF seems rather too heavy.
I am actually planing to do more GUI work soon, and still can't decide whether I should stick with rather pathetic WinForms or take huge risk with WPF.
Leave a comment:
-
Yes that part's fine, it's the whole "run a loop to see what's changed" aspect that seems to totally fly in the face of how a GUI app should work... though to be fair an update loop is not that unusual when coders can't find how to make the GUI behave as it should.Originally posted by AtW View PostGUI update function in underlieing object can be called by the Timer thread which is ok to change GUI, so if you want you can keep your GUI update implementation inside your classes.
Leave a comment:
-
Got to agree with ATW here. I found the dispatcher object was the recommended solution, although I am not ruling out Dimbo Prawn's solution, that needs careful thought and if that has more merit then I shall implement that. As DP pointed out, the robustness and maintainability of the end product is key here. I am grateful for the feedback as it gives me a well rounded poll of opinions and I can add better value to the customer by not being afraid to ask.Originally posted by AtW View PostWe 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
Perhaps DP was having a bad day, or perhaps he took my binding an array to a datagrid thread far too seriously. I can see that my posts being my only input into his otherwise dull existence he would get a bad opinion of me and don't blame him for that. I have good underpinning knowledge and experience of C, C++, C# and multithreading.
I had just not realised what a c<nt WPF is when it comes to handling this tulip. I fully agree with ATW that each object should have a better implementation of cross thread chat for something as simple as updating a label caption FFS.
Praps
MyBstardLabel.Caption.UpdateByDispatcher(Value)
I dunno but would cut out a lot of the ball ache.
Leave a comment:
-
GUI update function in underlieing object can be called by the Timer thread which is ok to change GUI, so if you want you can keep your GUI update implementation inside your classes.Originally posted by d000hg View PostTo 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.
Leave a comment:
-
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.Originally posted by AtW View PostPersonally 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
Leave a comment:
-
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.Originally posted by d000hg View Postthough being able to do GUI stuff cross-thread would be nice, are there design issues such as performance to think about?
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
Leave a comment:
-
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?Originally posted by AtW View PostHow is it easier than...
Leave a comment:
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers

Leave a comment: