// Demonstrates how to create a sequence static void Setup() { if (usingFileLog) { // Setup a FileRecordSequence sequence = (IRecordSequence) new FileRecordSequence(logPath); Console.WriteLine("Successfully created FileRecordSequence"); } else { // Setup a LogRecordSequence LogRecordSequence lrs = new LogRecordSequence(logPath, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); // Add two extents to the log record sequence // Some LogRecordSequence operations require more than one sequence lrs.LogStore.Extents.Add(logContainer0, containerSize); lrs.LogStore.Extents.Add(logContainer1); sequence = lrs; Console.WriteLine("Successfully created LogRecordSequence"); } // Create a total percentage processor time performance counter cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); cpuCounter.NextValue(); }
static SequenceNumber AppendRecord(IRecordSequence sequence, string message, SequenceNumber user, SequenceNumber previous) { MemoryStream data = new MemoryStream(); BinaryWriter writer = new BinaryWriter(data); writer.Write(message); ArraySegment <byte>[] segments; segments = new ArraySegment <byte> [1]; segments[0] = new ArraySegment <byte>(data.GetBuffer(), 0, (int)data.Length); return(sequence.Append(segments, user, previous, RecordAppendOptions.None)); }
// Demonstrates how to create a sequence static void Setup() { if (usingFileLog) { // Setup a FileRecordSequence sequence = (IRecordSequence)new FileRecordSequence(logPath); Console.WriteLine("Successfully created FileRecordSequence"); } else { // Setup a LogRecordSequence LogRecordSequence lrs = new LogRecordSequence(logPath, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); // Add two extents to the log record sequence // Some LogRecordSequence operations require more than one sequence lrs.LogStore.Extents.Add(logContainer0, containerSize); lrs.LogStore.Extents.Add(logContainer1); sequence = lrs; Console.WriteLine("Successfully created LogRecordSequence"); } // Create a total percentage processor time performance counter cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); cpuCounter.NextValue(); }