I would like to check if the user will make a kepress again after the first one to implement a pause function in a while cycle. The console window is not on focus so I can't use Console.Read()
while (true)
        {
            if (GetAsyncKeyState(0x21) != 0) 
                break;  //work just fine, if ESC press it exit while
            if (GetAsyncKeyState(0x05) != 0)
            {
                sw.Start();
                while (sw.ElapsedMilliseconds < 2000)
                {
                    // if side mouse button is press, it wait 2sec, work just fine
                }
                sw.Reset();
            }
            if (GetAsyncKeyState(0x42) != 0)
            {
                while (GetAsyncKeyState(0x42) == 0)
                {
                   // wait the second B pressing to resume  but it dosen't work
                }
             
            }
  main_function();
}
This code seems to not work, I check GetAsyncKeyState with writeline and it seems that it get the keypressed state for few ms so the pause cicle will end. I seems that in console c# I can't use ad hoc functions that c# have for forms to check it.
Thanks!