<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net%2FData_Structure%2FIDisposable</id>
		<title>VB.Net/Data Structure/IDisposable - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net%2FData_Structure%2FIDisposable"/>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/Data_Structure/IDisposable&amp;action=history"/>
		<updated>2026-04-05T15:53:42Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net/Data_Structure/IDisposable&amp;diff=1012&amp;oldid=prev</id>
		<title> в 16:40, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/Data_Structure/IDisposable&amp;diff=1012&amp;oldid=prev"/>
				<updated>2010-05-26T16:40:06Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 16:40, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net/Data_Structure/IDisposable&amp;diff=1013&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/Data_Structure/IDisposable&amp;diff=1013&amp;oldid=prev"/>
				<updated>2010-05-26T12:45:45Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Dispose - called when we need disposing==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
Imports System&lt;br /&gt;
Imports System.Drawing&lt;br /&gt;
Imports System.Data&lt;br /&gt;
Imports System.IO&lt;br /&gt;
Imports System.Collections&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
Imports System.Drawing.Printing&lt;br /&gt;
Public Class MainClass&lt;br /&gt;
    Shared Sub Main()&lt;br /&gt;
        Dim file As New MyFile(&amp;quot;c:\FinalizeDemo.txt&amp;quot;)&lt;br /&gt;
        file.AddText(&amp;quot;Hello, world!&amp;quot;)&lt;br /&gt;
        &amp;quot; now, clear the reference to the object...&lt;br /&gt;
        file.Dispose()&lt;br /&gt;
        file = Nothing&lt;br /&gt;
        &amp;quot; wait for the user to press return...&lt;br /&gt;
        Console.WriteLine(&amp;quot;Press Return to collect the garbage...&amp;quot;)&lt;br /&gt;
        &amp;quot; force a collect...&lt;br /&gt;
        GC.Collect()&lt;br /&gt;
        &amp;quot; wait for the user to quit...&lt;br /&gt;
        Console.WriteLine(&amp;quot;Press Return to quit...&amp;quot;)&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
&lt;br /&gt;
Public Class MyFile&lt;br /&gt;
    Implements IDisposable&lt;br /&gt;
    Private stream As FileStream&lt;br /&gt;
    Private isDisposed As Boolean&lt;br /&gt;
&lt;br /&gt;
    Public Sub New(ByVal filename As String)&lt;br /&gt;
        stream = New FileStream(&amp;quot;test.txt&amp;quot;, FileMode.OpenOrCreate)&lt;br /&gt;
        Console.WriteLine(&amp;quot;Object &amp;quot; &amp;amp; GetHashCode() &amp;amp; &amp;quot; created.&amp;quot;)&lt;br /&gt;
        Console.WriteLine(&amp;quot;Using file: &amp;quot; &amp;amp; filename)&lt;br /&gt;
    End Sub&lt;br /&gt;
    Public Sub AddText(ByVal buf As String)&lt;br /&gt;
        If isDisposed = True Then&lt;br /&gt;
            Throw New ObjectDisposedException(&amp;quot;I&amp;quot;ve been disposed!&amp;quot;)&lt;br /&gt;
        End If&lt;br /&gt;
        Dim writer As New StreamWriter(stream)&lt;br /&gt;
        writer.WriteLine(Date.Now)&lt;br /&gt;
        writer.WriteLine(buf)&lt;br /&gt;
        writer.Close()&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
    Public Sub Dispose() Implements System.IDisposable.Dispose&lt;br /&gt;
        If isDisposed = True Then Return&lt;br /&gt;
        &lt;br /&gt;
        stream.Close()&lt;br /&gt;
        stream = Nothing&lt;br /&gt;
        isDisposed = True&lt;br /&gt;
        GC.SuppressFinalize(Me)&lt;br /&gt;
        Console.WriteLine(&amp;quot;Object &amp;quot; &amp;amp; GetHashCode() &amp;amp; &amp;quot; disposed.&amp;quot;)&lt;br /&gt;
    End Sub&lt;br /&gt;
    Protected Overrides Sub Finalize()&lt;br /&gt;
        Dispose()&lt;br /&gt;
        Console.WriteLine(&amp;quot;Object &amp;quot; &amp;amp; GetHashCode() &amp;amp; &amp;quot; finalized.&amp;quot;)&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Use IDisposable==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
Imports System&lt;br /&gt;
Imports System.Runtime.InteropServices&lt;br /&gt;
Imports System.Drawing&lt;br /&gt;
Imports System.ruponentModel&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
Imports System.IO&lt;br /&gt;
Imports System.Xml.Serialization&lt;br /&gt;
Public Class MainClass&lt;br /&gt;
    &lt;br /&gt;
    Shared Sub Main(ByVal args As String())&lt;br /&gt;
        Dim i As Integer = 0&lt;br /&gt;
        i += 1&lt;br /&gt;
        Dim obj As New Named(&amp;quot;Dispose &amp;quot; &amp;amp; i)&lt;br /&gt;
        obj.Dispose()&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
    Public Class Named&lt;br /&gt;
        Implements IDisposable&lt;br /&gt;
        Public Name As String&lt;br /&gt;
        Public Sub New(ByVal new_name As String)&lt;br /&gt;
            Name = new_name&lt;br /&gt;
        End Sub&lt;br /&gt;
        &amp;quot; Free resources.&lt;br /&gt;
        Protected Overrides Sub Finalize()&lt;br /&gt;
            Dispose()&lt;br /&gt;
        End Sub&lt;br /&gt;
        &amp;quot; Display our name.&lt;br /&gt;
        Public Sub Dispose() Implements System.IDisposable.Dispose&lt;br /&gt;
            Static done_before As Boolean = False&lt;br /&gt;
            If done_before Then Exit Sub&lt;br /&gt;
            done_before = True&lt;br /&gt;
            Console.WriteLine(Name)&lt;br /&gt;
        End Sub&lt;br /&gt;
    End Class&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>