public bool CheckZsyncLoop(Process process, string data, ITransferProgress progress) { // By not resetting the loopdata/counts we set ourselves up for a situation where it's possible to detect loops that span multiple lines.. if (!ZsyncLoop.IsMatch(data)) return false; if (progress.ZsyncLoopData == null) { progress.ZsyncLoopData = data; progress.ZsyncLoopCount = 0; return false; } if (progress.ZsyncLoopData.Equals(data, StringComparison.OrdinalIgnoreCase)) { var loopCount = ++progress.ZsyncLoopCount; if (loopCount < 2) return false; if (!process.SafeHasExited()) process.TryKill(); return true; } progress.ZsyncLoopData = data; progress.ZsyncLoopCount = 0; return false; }