In my WPF application I want to open a console and a WPF window at the same time (I would type commands in the console, which would influence the content of the window at runtime). Unfortunately, the console opens first and doesn't let the WPF window open, until it ends its work (after the console closes, the window opens). My code:
using System;
using System.Runtime.InteropServices;
namespace MaszynaTest
{
public partial class MainWindow
{
[DllImport("Kernel32")]
public static extern void AllocConsole();
[DllImport("Kernel32")]
public static extern void FreeConsole();
public MainWindow()
{
InitializeComponent();
AllocConsole();
Console.WriteLine("Type something: ");
Console.ReadLine();
}
}
}