LogRecordSequence.AdvanceBaseSequenceNumber Method (SequenceNumber)


Moves the base sequence number of the log forward. This method cannot be inherited.

Namespace:   System.IO.Log
Assembly:  System.IO.Log (in System.IO.Log.dll)

public void AdvanceBaseSequenceNumber(
	SequenceNumber newBaseSequenceNumber


Type: System.IO.Log.SequenceNumber

Specifies the new base SequenceNumber for the log. This must lie in the range between the current base sequence number and the last sequence number of the log inclusively.

Exception Condition

newBaseSequenceNumber is not valid for this sequence.


A new or existing archive tail or base of the active log is invalid.


newBaseSequenceNumber is not between the base and last sequence numbers of this sequence.


The request could not be performed because of an unexpected I/O exception.


The request could not be performed because of an I/O device error.


The specified log does not have any extents. One or more extents must be created before a record sequence may be used.


The method was called after the sequence has been disposed of.


There is not enough memory to continue the execution of the program.


Access for the specified log sequence is denied by the operating system.


The record sequence is full.

This method is often used with the TailPinned event to free up space in a record. The TailPinned event indicates that the tail of the sequence (that is, the base sequence number) needs to be moved forward to free up space. Freeing space can be done by either writing restart areas using the WriteRestartArea method, or truncating the log and using the AdvanceBaseSequenceNumber method to advance the base sequence number of a log to the one specified by the newBaseSequenceNumber parameter. The code sample in the Example section demonstrates the second approach.

Note that calling this method is the same as setting a new base sequence number using the WriteRestartArea method, except that no restart record is written to the log.

This example shows how to use the AdvanceBaseSequenceNumber method with the TailPinned event to free up space in a log sequence.

recordSequence.RetryAppend = true;
recordSequence.TailPinned += new EventHandler<TailPinnedEventArgs>(HandleTailPinned);

void HandleTailPinned(object sender, TailPinnedEventArgs tailPinnedEventArgs)
   // tailPinnedEventArgs.TargetSequenceNumber is the target 
   // sequence number to free up space to.  
   // However, this sequence number is not necessarily valid.  We have
   // to use this sequence number as a starting point for finding a
   // valid point within the log to advance toward. You need to
   // identify a record with a sequence number equal to, or greater
   // than TargetSequenceNumber; let's call this 
   // realTargetSequenceNumber. Once found, move the base



.NET Framework
Available since 3.0
Return to top