[Mono-list] .NET Remoting and Hashtable
Michał Ziemski
rook at roo.k.pl
Thu Mar 27 07:08:03 EDT 2008
Hi!
Does your Hashtable sit in a MarshalByRef class or a [Serializable] one?
If the latter is the case then each connecting node works on its
separate copy.
Are you positive yor class is marshaled as a singleton rather than
single-call?
Other than that, only putting: "lastSeen[n] = DateTime.Now;" in the
method body will be a faster solution.
You should also consider using "lock(lastSeen)" if more than one client
can be connected at a time.
Cheers!
Michał Ziemski
nemesis35 pisze:
> Hi,
>
> we work on a project of distributed system where we use the technology
> dotNET Remoting. But we have there a small issue.
>
> We have two types of nodes there, managers and storages. They both use the
> same method (the method is in dll file - manager and storage have the same
> copy of this file).
> The method is:
>
>
> public void UpdateLastSeen(Node n)
> {
> if (lastSeen.ContainsKey(n))
> lastSeen[n] = DateTime.Now;
> else
> lastSeen.Add(n, DateTime.Now);
> }
>
> // Node n - is our own object
> // lastSeen is hashtable (key is our own object Node, value is DateTime)
>
> Problem:
> The both nodes - managers and also storage peridiocally call this method,
> while one of them works well, another one does somethig different with the
> same code.
> For example the topology is point-to-point, one manager, one storage.
> Storage updates active status of the manager well, but manager can't
> recognize that it has is connected stil the same node - the same storage.
> The result is that the manager does not overwrite the time of last seen of
> the node storage, but by timer click it adds allways a new entry into the
> hashtable. With the same code storage works great.
>
> No idea where the problem could be, maybe the copy of the object Node is not
> the same like in the object stored in the hashtable??
> Hope that someone will understand what we tried to explain;) and help.
>
> Thanks a lot
>
> Regards,
>
> michal kohut
>
More information about the Mono-list
mailing list