Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net remoting: Update already serialized objects

I got a MarshalByRefObject named "DefaultMeasurement", which contains a List of IPoint-objects.

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 first retrieving the DefaultMeasurement object from the server all the points get serialized and during all subsequent calls to DefaultMeasurement.Points I get the list that was correct upon startup of my client. But in the meantime the state of at least one object in that list might have changed and I don't get that current state, although in the server that state gets updated. How do I force an update of that list?

further clarification:
- it will work once I do DefaultPoint : MarshalByRefObject, but that is not an option as it negatively affects performance
- by 'update' I mean changes to existing objects on the server, no adding / removing on the list itself
- I might have up to 80k DefaultPoint objects

like image 735
yas4891 Avatar asked May 06 '11 03:05

yas4891


1 Answers

Since you don't want the Point itself to be MarshalByRef (as that introduces a LOT of traffic if you have a substantial number of points), what I would recommend is that you have explicit methods that synchronize point values. After you've made a significant number of changes on the server, you call the SynchronizePoints() method, which includes new values for all of the points. Now the client-side proxy has an updated state. Better yet, remove the state from the object in the first place (since it's not really a direct reflection of server state) and instead use client-side objects that are instantiated as needed when gathering points from the server.

like image 180
Dan Bryant Avatar answered Nov 18 '22 08:11

Dan Bryant