0

How would I make it so that I have one main program with a background process that "listens" for catches (via a function like sendDebugInfo(Exception e) for example) and then unhide the second console and display the message but if the user closes the debug window it doesn't exit the program.

If the above isn't clear enough here is a simple version:

Console application 1 function helloWord() is used Console application 1 function helloWorld() sends a String to a second console window (but within the same project) The second console displays "hello world".

4
  • An exception may not travel well between processes. Commented Nov 27, 2012 at 22:43
  • the exception is sent via string. Commented Nov 27, 2012 at 23:06
  • Do you have one process with 2 console windows (not sure if it is possible...) or 2+ processes each with console window? Commented Nov 27, 2012 at 23:38
  • @JordanTrainor - Does the serialized exception provide access to inner exceptions and additional context (e.g. the call stack), or are you just trying to display some text elsewhere? Commented Nov 28, 2012 at 0:44

2 Answers 2

3

You are really asking about inter-process communication (IPC).

There are many ways to achieve IPC. I suggest you have a look at Named Pipes. They are easy to use and quite reliable.

http://msdn.microsoft.com/en-us/library/system.io.pipes.aspx

The basic idea behind Named Pipes is that you have a named resource that you can write messages to in one process and read messages from in the other process. The message can be anything you want. The processes connect to the pipe simply by using the pre-agreed name for it.

Sign up to request clarification or add additional context in comments.

Comments

2

Just for clarification, saying that you want two console applications running in different threads is somewhat misleading. Console applications typically run on different processes entirely and since threads are not shared between processes two console applications running in different threads is the norm. However when you say this explicitly it sounds like you're trying to run them on the same process but different threads which I'm not even sure is possible.

That said, Eric J. is right you really seem to be asking about IPC which can be performed in a number of ways. Named pipes is one way and TCP loopback is another. If you want these applications to run on separate machines at some point you're going to want to use TCP. Otherwise named pipes are a lot easier to deal with.

I'd suggest reading up on IPC, figuring out which method suits your needs and try to make it work. When you run into a specific issue like "my messages aren't getting through" or something then you should come back and search for a similar question or create a new question.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.