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);  

适用于