C
C#2y ago
Estal

❔ Updating text on main thread from running application WPF C Sharp

Heyo All. I have a wrapper I'm wrapping steamcmd in and the launcher is supposed to intercept the text output by steamcmd and put it into the launcher. The current code works
private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
if (!String.IsNullOrEmpty(outLine.Data))
{

App.Current.Dispatcher.Invoke((Action)delegate
{
textbox.AppendText(outLine.Data + Environment.NewLine);
});
}
}
private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
if (!String.IsNullOrEmpty(outLine.Data))
{

App.Current.Dispatcher.Invoke((Action)delegate
{
textbox.AppendText(outLine.Data + Environment.NewLine);
});
}
}
It works in the fact that it outputs and changes the textbox data on the main GUI. What I'm having issues with is it waits until the output is complete rather than a running line of information coming from the console. Does anyone by chance have any suggestions as to what I'm doing wrong?
3 Replies
Klarth
Klarth2y ago
I would use https://github.com/Tyrrrz/CliWrap#pull-based-event-stream (or the push-based event stream) instead of implementing this yourself Odds are you haven't setup the stream correct for asynchronous i/o though. Read the docs to see if the event supports it.
Estal
Estal2y ago
will do. thanks I got it working. Seems like it's a steamcmd thing, but on the server it runs it's got a decent delay as well, so will look into that.
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.