.net: updating already serialized objects

I have a MarshalByRefObject called "DefaultMeasurement" that contains a list of IPoints.

public class DefaultMeasurement : MarshalByRefObject, IMeasurement { private List<IPoint> iPoints; public this[int aIndex] { get { return iPoints[aIndex];} } } [Serializable] public class DefaultPoint : IPoint, ISerializable { public int Value {get;set;} } 

When I first retrieve the DefaultMeasurement object from the server, all points receive serialization and during all subsequent calls to DefaultMeasurement.Points I get a list that was right when my client started. But at the same time, the state of at least one object in this list could change, and I do not get this current state, although the state is updated on the server. How to force update of this list?

further clarification:
- it will work as soon as I do DefaultPoint : MarshalByRefObject , but this is not an option, since it negatively affects performance
- "update" I mean changes to existing objects on the server, without adding / removing in the list itself
- I can have up to 80k DefaultPoint objects

+6
source share
2 answers

Since you don't want Point itself to be a MarshalByRef (since this introduces LOT of traffic if you have a significant amount of points), I would recommend that you have explicit methods that synchronize the values โ€‹โ€‹of the points. After you have made a significant number of changes on the server, you call the SynchronizePoints () method, which includes new values โ€‹โ€‹for all points. The client proxy now has an updated state. Even better, remove the state from the object first (since this is not a direct reflection of the serverโ€™s state) and instead use the client-side objects that are created when necessary when collecting points from the server.

+3
source

You will need to make a callback that notifies the client of changes to the server.

The notification may convey the identifier of the objects that have been changed, or the client may request a list of changed objects.

0
source

Source: https://habr.com/ru/post/887424/


All Articles