Skip to content

Commit 6b7dd4a

Browse files
committed
GetLastThousandLines -> GetLastHundredLines
1 parent 5499109 commit 6b7dd4a

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

PowerThreadPoolTest/MainWindow.xaml.cs

+11-13
Original file line numberDiff line numberDiff line change
@@ -222,25 +222,23 @@ private void OutputMsg(string msg)
222222
this.Dispatcher.Invoke(() =>
223223
{
224224
log.Text += msg + "\n";
225-
log.Text = GetLastThousandLines(log.Text);
225+
log.Text = GetLastHundredLines(log.Text);
226226
sv.ScrollToEnd();
227227
});
228228
}
229229

230-
private string GetLastThousandLines(string input)
230+
private string GetLastHundredLines(string str)
231231
{
232-
string[] lines = input.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
232+
string[] lines = str.Split(
233+
new[] { "\r\n", "\r", "\n" },
234+
StringSplitOptions.None
235+
);
233236

234-
if (lines.Length <= 1000)
235-
{
236-
return input;
237-
}
238-
else
239-
{
240-
string[] lastThousandLines = new string[1000];
241-
Array.Copy(lines, lines.Length - 1000, lastThousandLines, 0, 1000);
242-
return string.Join(Environment.NewLine, lastThousandLines);
243-
}
237+
string[] lastHundredLines = lines.Skip(Math.Max(0, lines.Length - 100)).ToArray();
238+
239+
string result = string.Join(Environment.NewLine, lastHundredLines);
240+
241+
return result;
244242
}
245243
}
246244
}

0 commit comments

Comments
 (0)