Vadym Stetsyak wrote:
IMO WebService will be inefficient in this scenario.
you can use simple lock statement in the server, and wrap the access to
array.
e.g.
public int Count
{
get { lock(this) { return ( _array.Length ); } }
}
This really would not be a lot of help. You lock the object then get the
length and then return. Now he has a length that might change in the
next fraction of a second by another thread so any logic he does on it
would be in error.
You should design an object to manage your data. The applications should
never get direct access to the array. This smart object should then have
methods to support the business logic that the applications need. The
methods would do their work within a lock block to ensure thread safety.
The applications should know nothing about locking the data structures.
Just the new manager object should. Another good practice is to use
queues for requesting work of the manager object in case it needs to do
some background calculations. This is a good way to avoid deadlock
situations.
Hope this help.
Leon Lambert