I have 2 simple applications the 1st one makes a string and the 2nd one reads the string..
App1 (ConsoleApp4.exe)
for (int i = 0; i < 16; i++)
{
string x = " " + GetRandomString(6);
Console.WriteLine("line " + (i + 1) + x);
Thread.Sleep(3000);
}
App2
Process process = new Process();
process.StartInfo.FileName = @"ConsoleApp4.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
{
// Prepend line numbers to each line of the output.
if (!String.IsNullOrEmpty(e.Data))
{
lineCount++;
//output.Append("\n[" + lineCount + "]: " + e.Data);
Console.WriteLine("\n[" + lineCount + "]: " + e.Data);
}
});
process.Start();
// Asynchronously read the standard output of the spawned process.
// This raises OutputDataReceived events for each line of output.
process.BeginOutputReadLine();
process.WaitForExit();
// Write the redirected output to this application's window.
Console.WriteLine(output);
process.WaitForExit();
process.Close();
Console.WriteLine("\n\nPress any key to exit.");
Console.ReadLine();
I want to change App1 to send an object instead of a string. The object would be
class Message
{
string AMessage
bool IsItTrue
int MyFavoriteNumber
}
How can I alter App1 to send a custom object instead of a string. Then how can I alter App2 to read the custom object.
Also I would like to avoid Console.(anything) to send the message if possible