Rocky, can you call Dispose() on the DataPortal.ReleaseProxy()

Rocky, can you call Dispose() on the DataPortal.ReleaseProxy()

Old forum URL: forums.lhotka.net/forums/t/4182.aspx


slabanum posted on Wednesday, January 16, 2008

Just got my hands on the 3.0 e-book and was happy to find that the ReleaseProxy() has been implemented since we implemented our own channel.

Can I make a request that the ReleaseProxy() implement something like the the below snippet so that it automatically releases the connections in our custom proxy?  Another idea is to have IDataPortalProxy implement IDisposable?

If mPortal IsNot Nothing Then

    Dim o As Object = mPortal

   Dim dispType As System.Type = o.GetType().GetInterface("System.IDisposable")

   If dispType IsNot Nothing Then

      CType(o, IDisposable).Dispose()

   End If

End If

Thanks.

 

 

 

RockfordLhotka replied on Thursday, January 17, 2008

This is a good idea.

I don't think having IDataPortalProxy implement IDisposable is a good idea, because that would imply that proxies should somehow be disposed in normal usage - and that's not practical in most apps. Typically the proxy is created and cached during the entire life of the AppDomain.

But this release method is an exception to that, and you are right that the proxy should be disposed when it is released.

Copyright (c) Marimer LLC