[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [DotGNU]question about Finalize in C#
From: |
Chris Smith |
Subject: |
Re: [DotGNU]question about Finalize in C# |
Date: |
Wed, 9 Oct 2002 13:20:50 +0100 |
On Thursday 05 September 2002 00:05, Rhys wrote:
> 1. Implement the IDisposable interface and its "Dispose" method.
> 2. "Dispose" closes handles, sockets, etc, if they aren't null,
> and then sets them to null.
> 3. "Close" and "Finalize" call "Dispose" internally.
>
> It is possible that "Dispose" may be called multiple times
> (e.g. once in "Close" and again from "Finalize"), so it must
> be hardened against such usage.
>
> Implementing the IDisposable interface allows you to use the
> "using" construct. e.g.
>
> using (FileStream file = new FileStream("xyz"))
> {
> ...
> }
>
> The "using" statement automatically calls "Dispose" when the
> statement body ends or throws an exception.
Dispose doesn't work yet does it? Or even 'using( ..... )'.
I just want to check that I've not got something broken.
Attached is a standard test prog for such things, from which I get the
output:
Construct Bod with id 2
End
Which is far less than expected.
Sorry if knowledge of this has been made public elsewhere, I can't find it.
Cheers,
Chris
--
Chris Smith
Technical Architect - netFluid Technology Ltd.
"Internet Technologies, Distributed Systems and Tuxedo Consultancy"
E: address@hidden W: http://www.nfluid.co.uk
dispose.cs
Description: Text Data
- Re: [DotGNU]question about Finalize in C#,
Chris Smith <=