async Task EasyRecvDataOneLineRecvCallbackAsync(PipeStream st) { bool returnedFalseOnce = false; var r = new BinaryLineReader(st); while (true) { List <Tuple <Memory <byte>, bool> >?lines = await r.ReadLinesWithTimeoutAsync(1000); if (lines == null) { break; } foreach (var line in lines) { string lineDecoded = line.Item1._GetString(this.OutputEncoding); if (returnedFalseOnce == false) { if (this.Options.EasyOneLineRecvCallbackAsync != null) { try { bool ret = await this.Options.EasyOneLineRecvCallbackAsync(lineDecoded); if (ret == false) { returnedFalseOnce = true; } } catch (Exception ex) { ex._Debug(); returnedFalseOnce = true; } if (returnedFalseOnce) { TaskUtil.StartAsyncTaskAsync(async() => { await Task.Yield(); KillProcessInternal(); await Task.CompletedTask; })._LaissezFaire(true); } } } } } }
async Task EasyPrintRealTimeRecvDataPrintCallbackAsync(PipeStream st) { var r = new BinaryLineReader(st); while (true) { List <Tuple <Memory <byte>, bool> >?lines = await r.ReadLinesWithTimeoutAsync(1000); if (lines == null) { break; } foreach (var line in lines) { string tagStr = ""; if (this.Options.PrintTag._IsFilled()) { tagStr = $"{this.Options.PrintTag}: "; } string lineDecoded = line.Item1._GetString(this.OutputEncoding); string str = tagStr + lineDecoded; if (line.Item2 == false) { str += " [...!!pending!!...]"; } using (await WriteLineLocker.LockWithAwait()) { Con.WriteLine(str); } } } }