Hello. I have a little app that uses windows forms. Part of that app should be functionality that would show content of a log file in realtime as it’s added to the log.
I know I can do something like
Get-Content -Path "C:\Logs\log.txt" -Wait | Out-GridView -Wait
but that’s not ideal as it blocks the script and I’d like the display the output in win forms controls like RichTextBox. I’ve tried creating a timer and updating the RichTextBox content with the log file content on timer tick, but that loads the log file every time and is therefore terribly inefficient. Surely there must be better way to do this…
I’ve also found this code https://www.codeproject.com/Tips/371229/Live-Log-Viewer but I can’t really translate the C# code to PSH.
Can anyone help?