If you use only certain properties such as text value for text label, it means that you can always return current most up to date (changed immediately after all) internal value, and actual representation on screen can be updated later: this in principle is no different to dirty reads in the database - it is faster but there may be small risk of reading old data, even though since this is GUI we talking about its not something very critical.
- 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!
.NET 2.0/.NET 1.1/Com Interop
Collapse
X
-
-
I don't think that is in dispute. But the fact is it is write only. you can't get to any of the properties since they are not thread safe.Originally posted by DimPrawnYou CAN update the controls on a different thread.
In 1.1 in practice this doesn't seem to be a problem, but for those you do need access to you have to override them and put the access in a lock block (or more typically just hope for the best judging by the reivews I have done
).
In 2.0 it appears to be worse. AIUI property access from a thread other than the owning thread just throws a "ha ha wrong thread" type exception.
Generally then it does become necessary to maintain a copy of the property locally and acess the copy via a lock block. But this still becomes a pain because methods which update the property will also need to be overridden to update the local copy. Then of course there is the issue of the fact that some control visual representations are only controlled by property access. Although there is usually a workaround (e.g. text box 'text' -> can use ClearText then AppendText but this gives more flicker).
I am sure there is some visual element somewhere in one of the control the control that can only be updated by property access. So now you are truly stuffed. This then does involve a timer callback opr similar.
It would appear you can solve a lot of these issues in 2.0 with a backgroundworker. But that is only going to work if the second thread occurs as a result of user interaction. How will it help when the second thread is independant? Perhaps it's monitoring a device on the RS232 and needs to give some feedback as to how it is working.
Ultimately if you have a multi thread app (and one is encouraged to use other threads rather than timers etc) then you do need a threadsafe UI. The fact that one is not provided is, ultimately, complete pants.Comment
-
Well said.Originally posted by ASBThe fact that one is not provided is, ultimately, complete pants.
Now confession time - DimPrawn while at M$, did you work on .NET GUI? Be honest...Comment
-
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

Comment