c# - Locking on property without copying data -


I want to use the property which can be modified by other code and make sure that its access thread Of course, this question was already done.

However, in my special circumstances, I have different, specific concerns. First of all, the multi-threaded access / modification scenario is probably a rare opportunity, and I do not care about performance on this occasion. Apart from this, this property is very large - it's a zarded array that can be acquired in size up to 4096 by 4096, and I would like to copy it to as much as possible. And, finally, I want the class interface to be easy to use - which is not, because this requires the user to lock a particular SyncRoot.

Is there a solution that will not require my property thread-safe, extra copy and will not allow the subscriber to use the recipient (setter is private) without remembering anything lock?

If you are going to ease of use, then provide the .NET built-in thread-safe storage class Does that lock for you

You can do a

  concurrent blogs & lt; Float [] & gt;  

If you do your role, then I worry more about Deadlock in the future than the display inadvertently. When you start locking outside your class, the deadlock is a very real risk.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -