共用方式為


LogRecordSequence.Dispose 方法

定義

釋放由元件使用的資源。

public:
 virtual void Dispose();
public void Dispose ();
abstract member Dispose : unit -> unit
override this.Dispose : unit -> unit
Public Sub Dispose ()

實作

例外狀況

已在處置序列之後呼叫此方法。

沒有足夠的記憶體可以繼續執行程式。

範例

此範例示範如何使用 Dispose 來釋放資源:

// Create log stream 1.
        sequence1 = new LogRecordSequence(logStream1,
            FileMode.OpenOrCreate,
            FileAccess.ReadWrite,
            FileShare.ReadWrite);

// Log Extents are shared between the two streams.
// Add two extents to sequence1.
        sequence1.LogStore.Extents.Add("MyExtent0", containerSize);
        sequence1.LogStore.Extents.Add("MyExtent1");

// Create log stream 2.
        sequence2 = new LogRecordSequence(logStream2,
            FileMode.OpenOrCreate,
            FileAccess.ReadWrite,
            FileShare.ReadWrite);
' Create log stream 1.
        sequence1 = New LogRecordSequence(logStream1, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)

' Log Extents are shared between the two streams. 
' Add two extents to sequence1.
        sequence1.LogStore.Extents.Add("MyExtent0", containerSize)
        sequence1.LogStore.Extents.Add("MyExtent1")

' Create log stream 2.
        sequence2 = New LogRecordSequence(logStream2, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)
        Console.WriteLine();

// Cleanup...
        sequence1.Dispose();
        sequence2.Dispose();
        Console.WriteLine()

' Cleanup...
        sequence1.Dispose()
        sequence2.Dispose()

適用於