Game Development Reference
In-Depth Information
private void LaunchButton_Click(object sender, EventArgs e)
{
string message = “\”Hello World\””;
LaunchConsoleApplication(“SimpleConsoleApplication.exe”,
“5 “ + message);
}
The following code shows the logic for the demo console application.
static void Main(string[] args)
{
int count = Convert.ToInt32(args[0]);
string message;
if (args[1] != null && args[1].Trim().Length > 0)
message = args[1];
else
message = “No Message”;
for (int index = 0; index < count; index++)
{
Console.WriteLine(message + “ - # “ + (index + 1).ToString());
System.Threading.Thread.Sleep(300);
}
}
Conclusion
In this chapter, I discussed how to launch a console application process with para-
meters and redirect output to a Windows Forms application. This technique is very
useful when you want to create a graphical user interface for an already existing
console utility, while saving as much development and maintenance time as possible.
Search Nedrilad ::




Custom Search