c# - Properly set a list of COM objects to a new value -
suppose have list of com objects property in class :
public list<legacycomobjects> legacycomobjects { get; set; }
what best way set property new value? should classic .net way or should release objects before setting because memory leaks may happen? think of :
private list<legacycomobjects> _legacycomobjects ; public list<legacycomobjects> legacycomobjects { { return _legacycomobjects; } set { if (_legacycomobjects!= null) { _legacycomobjects.foreach(o => { marshal.releasecomobject(o); o = null; }); } _legacycomobjects= value; } }
Comments
Post a Comment