static void ScanThread() { byte[] result; while (true) { while (!iter.GetNext(out result, out _, out _)) { // For finite end address, check if iteration ended // if (currentAddress >= endAddress) return; iter.WaitAsync().GetAwaiter().GetResult(); } // Memory pool variant: // iter.GetNext(pool, out IMemoryOwner<byte> resultMem, out int length, out long currentAddress) if (Different(result, staticEntry)) { throw new Exception("Invalid entry found"); } // Example of random read from given address // (result, _) = log.ReadAsync(iter.CurrentAddress).GetAwaiter().GetResult(); // Truncate until start of most recently read page log.TruncateUntilPageStart(iter.NextAddress); // Truncate log until after most recently read entry // log.TruncateUntil(iter.NextAddress); } // Example of recoverable (named) iterator: // using (iter = log.Scan(log.BeginAddress, long.MaxValue, "foo")) }