Brian, The specific WCF case that you mention, yes there is specific cleanup that is required that IDisposable doesn't cover.
However, this is the case wherever you need *any* specialized cleanup. This is more a fault of those that extended ICommunicationObject from IDisposable, not the other way around. Long story short, unless you have *very* specialized situations around cleanup which requires specialized logic on the client, IDisposable is not the case. Everything I've seen in Lucene.NET *doesn't* fall in this category and is suitable for having IDisposable implementations. Granted, it's not as easy as slapping on the IDisposable interface and then having it call Close (note, a Close method with no return value and no parameters is a good indication that IDisposable is applicable here), the finalizers that *should* be implemented should *not* call IDisposable on references they hold, but it's not rocket science either. - Nick On Jun 1, 2012, at 2:59 PM, "Brian Sayatovic" <[email protected]> wrote: > Crap! I went to look up the original information I read about the using vs. > try/finally and instead stumbled upon MSDN's own documentation or it > confirming your statement: > http://msdn.microsoft.com/en-us/library/yh598w02(v=vs.90).aspx. However, > MSDN also documents, for example within their WCF pages, about the risks of > using "using" if you're not fully aware: > http://msdn.microsoft.com/en-us/library/aa355056.aspx. There's also supposed > internal discussions: > http://social.msdn.microsoft.com/forums/en-US/wcf/thread/4cdc67e0-3069-4d3b-b94f-27e2b8ff4429/. > They're all around special clean-up scenarios and situations where your > cleanup itself might fail but not be obvious in the syntax of the code. > Those are all more prevalent with WCF, I suspect, than Lucene.NET. > > > Brian Sayatovic > Senior Software Architect > > 866-218-1003 toll-free ext. 8936 > 937-235-8936 office > 4540 Honeywell Ct. Dayton, OH 45424 > > > This message may contain confidential/proprietary information from the > CINgroup or its subsidiaries. > If you are not an intended recipient, please refrain from the disclosure, > copying, distribution or use of this information. All such unauthorized > actions are strictly prohibited. If you have received this transmission in > error, please notify the sender by e-mail and delete all copies of this > material from any computer. > > > -----Original Message----- > From: Nicholas Paldino [.NET/C# MVP] [mailto:[email protected]] > > 1) That is not true, using ultimately compiles down to a try/finally. It's > always called no matter how the block is exited. > > 2) This is a fault of the implementation. It is up to the implementer to > create a finalizer that disposes of resources that don't implement IDisposabe > but need disposal (think raw handles). Regardless, try/finally doesn't > improve the experience here; whatever method you use to have the caller > deterministically release resources won't do any good if the finalizer isn't > implemented correctly. Implementing IDisposable doesn't get you special > consideration in the finalizer. >
