1

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();
        }
    }
}
xa19
  • 43
  • 1
  • 7

1 Answers1

0

What you need is inter process communication, not sure just running on different threads would solve the entire problem.

Refer to example here on how two processes can communicate using named pipes : https://code.msdn.microsoft.com/windowsdesktop/Interprocess-Communication-858cc9c7

Sanjeevakumar Hiremath
  • 10,985
  • 3
  • 41
  • 46