0

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.

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
joey
  • 469
  • 1
  • 6
  • 22
  • `command.write()`? Whatever it is you can make it do whatever you want... There is really nothing SO can help you with based on information you've provided. – Alexei Levenkov Dec 08 '15 at 22:53
  • We now have multiple threads running 1 for each database. They all do a console.write(). We want to make a tab in a form application per database and only get the output from that thread and not the other threads. – joey Dec 08 '15 at 22:56

2 Answers2

2

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.

Community
  • 1
  • 1
Laura
  • 152
  • 1
  • 1
  • 11
  • unfortunately we cannot change the console.write() (my mistake i edited the question) because the code is used in more then 1 application. – joey Dec 08 '15 at 23:03
  • Well then there's 2 options, 1) "fake" your own `Console` class that has a method called `Write` and include that in your GUI application, or 2) write an abstraction layer that selects the correct one based on which application you're in. – Laura Dec 08 '15 at 23:07
0

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.

Dieter Meemken
  • 1,937
  • 2
  • 17
  • 22