To answer your question about redirecting console output:
You'll be better off changing the code to fire an event with the string you wish to output. Then in the UI add a handler for that event and in the handler update the text field.
To declare an event add something like this code in your processing class:
public event EventHandler<StringEventArgs> Process_Message;
where StringEventArgs
is a class based on EventArgs
that wraps the message for sending.
To fire the event add something like this code in your processing class:
Process_Message(this, new StringEventArgs(message));
To attach a message handler in your UI class:
process.Process_Message += Process_Message;
To handle the event add something like this code to your UI class:
private void Process_Message(object sender, StringEventArgs e)
{
Action action = () => UpdateStatus(e.Message);
{
Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, action);
}
else
{
action();
}
}
You need to do the threading test as the UI can't be updated from a different thread.
Then the UpdateStatus
method:
private void UpdateStatus(string message)
{
statusTextBox.Text = message;
}
Obviously you'll need to rename things to be appropriate to your application.
Look up events and EventArgs
in the MSDN.