共用方式為


LogRecordSequence.CreateReservationCollection 方法

定義

建立新的 ReservationCollection。 這個方法無法被繼承。

public:
 virtual System::IO::Log::ReservationCollection ^ CreateReservationCollection();
public System.IO.Log.ReservationCollection CreateReservationCollection ();
abstract member CreateReservationCollection : unit -> System.IO.Log.ReservationCollection
override this.CreateReservationCollection : unit -> System.IO.Log.ReservationCollection
Public Function CreateReservationCollection () As ReservationCollection

傳回

新建立的 ReservationCollection

實作

例外狀況

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

範例

您可以透過兩種方式執行保留,如下列範例所示。 您可以採用範例中的做法進行穩固的處理。 請注意,您只能在使用 CLFS 的 LogRecordSequence 類別時執行這項工作。

//Using the ReserveAndAppend Method  
ReservationCollection reservations = recordSequence.CreateReservationCollection();  
long[] lengthOfUndoRecords = new long[] { 1000 };  
recordSequence.ReserveAndAppend(recordData,  
                                                     userSqn,  
                                                     previousSqn,  
                                                     RecordSequenceAppendOptions.None,  
                                                     reservations,  
                                                     lengthOfUndoRecords);  
recordSequence.Append(undoRecordData,    // If necessary …  
                                    userSqn,  
                                    previousSqn,  
                                    RecordSequenceAppendOptions.ForceFlush,  
                                    reservations);  

// Using the Manual Approach  
ReservationCollection reservations = recordSequence.CreateReservationCollection();  
reservations.Add(lengthOfUndoRecord);  
try  
{  
   recordSequence.Append(recordData, userSqn, previousSqn, RecordAppendOptions.None);  
}  
catch (Exception)  
{  
   reservations.Remove(lengthOfUndoRecord);  
   throw;  
}  

recordSequence.Append(undoRecordData, userSqn, previousSqn, RecordAppendOptions.ForceFlush, reservations);  

適用於