Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I'm creating two APF applications.
APP-1: Parent Application.
APP-2: Child Application.

Scenario:
APP-2 is invoked from APP-1 based on a condition.
I'm using Process.Start and StartInfo.Arguments to invoke the APP-2 and pass some data to it.

APP-2 takes that data and works on it. There is a Final Data which I want to capture from APP-2 within APP-1 once it's closed.

Following is the code.

C#
string parameter = "INVK://param1/value1/param2/value2/";

			System.Diagnostics.Process launchAuthorApp = new System.Diagnostics.Process();
			launchAuthorApp.StartInfo.FileName = @"C:\APP2.exe";
			launchAuthorApp.StartInfo.Arguments = parameter;
			launchAuthorApp.OutputDataReceived += launchAuthorApp_OutputDataReceived;
			launchAuthorApp.Start();
			while (!launchAuthorApp.StandardOutput.EndOfStream)
			{
				string line = launchAuthorApp.StandardOutput.ReadLine();
			}



How do I set the output for APP-2?

Kinldy respond.

Thanks,
Abhishek

What I have tried:

I Tried
C#
System.Diagnostics.Debug.WriteLine("Output 123");

but not working.
I'm not sure if I'm moving in right direction.
Posted
Updated 28-Nov-16 19:26pm

1 solution

I think you have to redirect the output and use Console.WriteLine.

Mhm... maybe something like this[^] could help you

In your APP-1
C#
var launchAuthorApp = new System.Diagnostics.Process {
    StartInfo = {
          FileName               = @"C:\APP2.exe",
          UseShellExecute        = false,
          RedirectStandardOutput = true,
          Arguments              = "INVK://param1/value1/param2/value2/"
    }
};

launchAuthorApp.Start();

Console.WriteLine(launchAuthorApp.StandardOutput.ReadToEnd());


And in APP-2 (as example)
C#
static void Main(string[] args) {
    Console.WriteLine(args[0]);
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900