Re: Should the Dispose( ) method only run when there are no other references to an object?
- From: "Brian Gideon" <briangideon@xxxxxxxxx>
- Date: 21 Jan 2007 17:50:54 -0800
Steve,
It wouldn't. But, as the programmer you would know about other
references and code accordingly for those situations. In other words,
if you allow an object to be used in other threads don't dispose it
until those threads are done with it.
Brian
Steve Richter wrote:
I understand the IDisposable interface and how the using instruction
will call the Dispose method of an object.
What if a reference to an object is passed to a 2nd thread? And the
object contains a handle to an open file. The Dispose( ) method closes
the handle.
How would the Dispose( ) method called from the end of the using block
in the 1st thread know that references to the object still exists in
other threads?
thanks,
-Steve
.
- Follow-Ups:
- References:
- Prev by Date: Re: << and >> operators in c#
- Next by Date: Re: I use msdos in C# ???
- Previous by thread: Should the Dispose( ) method only run when there are no other references to an object?
- Next by thread: Re: Should the Dispose( ) method only run when there are no other references to an object?
- Index(es):
Relevant Pages
|