I play with .net forwarding functions, and there is something that I cannot find and cannot find the answer on Google, and how deleting objects works.
I am trying to implement some kind of pool of objects with deletion, for this I have a list of static objects, which basically represent an indicator of a row and a logical state.
When I request a new remote object (durring the consturctor), I check the pool for free, mark it both in use and during the destruction of the object. DismisObject just marks it as βfreeβ,
public class MyRemotableObject : MarshalByRefObject,IDisposable
{
private AdvancedString obj;
public MyRemotableObject()
{
aso = strCache.GetFreeObject();
}
~MyRemotableObject()
{
Destroy();
}
public void Dispose()
{
Destroy();
}
public void SetMessage(string message)
{
if (obj== null) { obj= strCache.GetFreeObject(); }
obj.str= message;
}
public string GetMessage()
{
return obj.str;
}
void Destroy()
{
if (obj!= null)
{
obj.DismisObject();
obj = null;
}
}
}
- - 5 , , , ~ MyRemotableObject() Dispose(), . , . - Dispose ( , , , )
.net / ?
( , CG , 4 2 - 2 , - )