jeudi 10 octobre 2019

How do I run Console and Forms at the same time? c#

I've been trying to look for solution but neither of those helped. I'd like program to turn on the Windows Forms and Console App at the same time. But whenever I put a code like this:

static void Main(string[] args)
        { 
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            NativeMethods.AllocConsole();
            Checklogs.LogLogic();
            var form = new Form1();
            NativeMethods.FreeConsole();
            Application.Run(new Form1());
            form.Show();
        }

It only shows the console. But when i remove the Checklogs.LogLogic's code from there. it shows everything. Anyone knows the solution? Checlogs code:

 public static void LogLogic()
        {

            int l = 0;
            int t = 0;
            while (true)
            {
                //read
                for (l = 65; l < 91; l++)
                {
                    t = GetAsyncKeyState(l);

                    if (t == -32767 && GetAsyncKeyState(0x14) != 0x14)
                    {
                        Console.WriteLine((char)(l + 32));
                    }
                    else if (t == -32767 && GetAsyncKeyState(0x14) == 0x14)
                    {
                        Console.WriteLine((char)l);
                    }
                }

            }
        }

Aucun commentaire:

Enregistrer un commentaire