joey
joey

Reputation: 466

Form with multiple command prompt outputs

We now have an command line application that runs for multiple databases. Each database has a separate thread. In those threads the application does some console.write(). We want to get those into an form application with tabs and each tab has a different database (and thread).

Is it possible to get get the console.write() output to a specific tab so we know what database has outputted the code or do we need to rewrite all the code? Which we cannot do because the code is used in multiple places.

Upvotes: 0

Views: 163

Answers (2)

Dieter Meemken
Dieter Meemken

Reputation: 1967

How do you start your programs? May be you can create an application, run a 'Process' instances for each of your programs and redirect the output. If you do that asynchron, it should be possible to capture all the outputs.

Upvotes: 0

Laura
Laura

Reputation: 152

Depending on how well you segregated your output from your logic currently, you can somewhat preserve a layer of your original application and only rewrite the output sections (effectively, doing what you just suggested: making command.write() instead dump to a form).

What I believe you're after is something like multiline textboxes in each tab that just show log output, correct?

You could replace command.write() with something like this extension method to aid you. You simply pass in the correct text box control, and also give it the line to log, and it will add it onto the text box.

One remaining thing to address now is that in a GUI-driven application, you shouldn't simply be blocking/waiting on database stuff on the main thread, or else it becomes unresponsive. So make sure that logic is moved somewhere else.

Upvotes: 2

Related Questions