For whatever their reason, the original .NET developers have decided to flip the IsDisposed
flag only if the disposed ToolStripItem
has non-null Owner
property (which you're kindly indirectly setting to null
line before). This doesn't seem to have any further impact - i.e. you can assume the ToolStripItem
is safely disposed despite this weird behaviour.
As for your broader question - the IDisposable
interface does not provide any way of checking if the object was disposed (and to make matters worse - classes implementing it do not have to guarantee an exception-free execution if it's called more than once (see MSDN)). You need to rely on the developers of said classes to provided some info if the object was actually disposed (which as can be seen in the ToolStripItem
example is not a fool proof method), or track this somehow in your code.
Having said all that, it rarely becomes a problem in real-life scenarios (though it's useful to be aware of it).