I needed to use console inside c# form application. I found AllocConsole while researching. My commands are working, but when I'm done in the console, I want to return to my form application, but when I close the console, the whole application closes.
I can't access my form application even if I want to leave it running in the background without closing the console, but my form application it's getting frozen
how can I solve this?
My Codes
using System.Runtime.InteropServices;
using System.Threading;
public Doxy0()
{
InitializeComponent();
}
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole();
private void button1_Click(object sender, EventArgs e)
{
AllocConsole();
a=lblbox1.Text;
int milliseconds = 2000;
Thread.Sleep(milliseconds);
Console.WriteLine("Activation Started", Console.ForegroundColor = ConsoleColor.Green);
Console.WriteLine("Activation Completed" + a, Console.ForegroundColor = ConsoleColor.White);
Console.ReadLine();
}