You question makes no sense.
You always pass around references to objects - you cannot pass an object by value.
As far as the OP's question is concerned you have entered a world of pain that IDisposable does not cope with. For IDisposable to work correcctly there has to be a strong notion of ownership of the object. You only have four options really:
1. Decide who is going to take responsibility for calling Dispose and stick to that architecturally
2. Let the finalizer talke care of releasing resources and don't call Dispose at all
3. Implement some form of reference counting architecture where everone "releases" their reference (calling a method) and then the object Disposes itself when the refcount goes to zero.
4. Clone the object before its passed to the controller so they each have an independent copy they can Dispose
As you can see, none of these is enormously attractive and some may be unsuitable for you architecture
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
web1110 wrote:
> Hi y'all.
>
> After looking in to this, I better elaborate.
>
> I have a control object. It operates it 2 modes:
>
> A. It can display itself. The display handled by a control display
> manager.
>
> B. It can be utilized without being displayed.
>
> Now, the situation I am confused about is as follows:
>
> A. I instantiate such a object.
> B. I give it to the control manager to display.
This would seem to be the critical point.
Are you giving it a reference (handle) to the object or the object itself?
> C. When the user is done, the control manager (which keeps a reference to
> the control in a stack) disposes of its copy.
> D. However, the class that instantiated the control in the first place
> wants to keep the object present for additional reference.
>
> What happens to the original object after the control manager disposes of
> its version?
>
> Thanx,
> Bill
>
>
--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.7.4 - Release Date: 18/03/2005
[microsoft.public.dotnet.languages.csharp]