Home > Blockchain >  Terminal window for a WPF application for live console output
Terminal window for a WPF application for live console output

Time:05-11

I know this question has come up here a few times, unfortunately the answers are outdated or didn't give me the result I wanted. AllocConsole doesn't seem to work that way either.

I need a terminal window for a WPF application for live console output. Whether embedded or as an external window.

In my application I have data that reads network packets via Photon. So this happens all the time without a break. If there is a problem in my app, this is the easiest place to look for the error.

A direct connection to a console window would be best, but I would also be satisfied with my own version of a console if it does not require a multiple of performance.

Does anyone have an idea how I can best do this? Simply ObservableCollection and then output by list?

Are there already such notification solutions?

CodePudding user response:

You might want to hop on over to the Terminal repo and show your support for microsoft/terminal#6999. We've got a WPF-backed terminal control in that repo that we've built, but it's not really production ready for third parties. Showing that you're interested in using it might help change the prioritization.

CodePudding user response:

If you're using .NET Core, you can create another logging provider and stream those updates to a UI.

If that's too big a paradigm shift, you can create a log reader that streams updates from a file on disk to a UI by opening a read-only stream and seeking to the file's end. This way would let you keep your logging implementation but requires considerations such as

  • Does the file exist? If not, start streaming when it comes into creation
  • If the logs have a rolling interval, which one do you pick up and when do you switch?
  • Filestreams don't always flush their contents to disk; you have to poke the file with a stick sometimes to get the log contents to flush.
  • and other reading-from-disk headaches.
  • Related