property access after Dispose()
From: dirk diggler (shoveyerspamupyer@ss.com)
Date: 09/20/02
- Next message: David Fanning: "NTFS + Impersonation + Asp.Net"
- Previous message: gt: "Context.User lifetime"
- In reply to: norm: "property access after Dispose()"
- Next in thread: Alex Kro: "Re: property access after Dispose()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "dirk diggler" <shoveyerspamupyer@ss.com> Date: Fri, 20 Sep 2002 01:38:09 -0700
just an opinion, but i think that it should be A - throw
exceptions on all attempts to access once disposed. This
is because, when you dispose of an object you are
explicitly saying i have finished with it (after all it
isn't absolutely necessary to dispose) and i want the
resources i have used to be freed up so they can be re-
used.
Just a guesss, but the properties that are not throwing
exceptions, could it be that Garbage Collection hasn't yet
happened for those yet?
>-----Original Message-----
>Hi,
>
>Microsoft's .NET documentation suggests that the object
>become "unusable" after a Dispose() is invoked on it.
>I've seen classes in the .NET class library throw
>exceptions when a method is called on a disposed method,
>which seems to be consistent all around. However, I've
>seen a mixed bag when it comes to properties of a
disposed
>object. Some properties throw exceptions and some do not
>when they're accessed after the dispose is called. I'm
>currently designing my own class library and I'm not sure
>exactly what approach I should take when properties are
>accessed on a disposed object. Should the disposed
>object ...
>
>a) always throw exceptions when properties are accessed
on
>a disposed object?
>b) return whatever property values that were present
>before the dispose was called?
>c) return the default values of the property
>d) only throw an exception if the property value cannot
be
>returned due to the resources freed by Dispose()?
>
>Any help is appreciated! Thanks!!
>
>- norm.
>.
>
- Next message: David Fanning: "NTFS + Impersonation + Asp.Net"
- Previous message: gt: "Context.User lifetime"
- In reply to: norm: "property access after Dispose()"
- Next in thread: Alex Kro: "Re: property access after Dispose()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|
|