public static Keys WaitKey(int delay)
{
Keys result = Keys.None;
Stopwatch watch = Stopwatch.StartNew();
foreach (CvWindowEx w in windows)
{
w.StartKeyCheck();
}
while (!ClosedAllWindows() && (delay <= 0 || watch.ElapsedMilliseconds < delay))
{
Application.DoEvents();
Thread.Sleep(1);
foreach (CvWindowEx w in windows)
{
if (!w.Created)
{
continue;
}
Keys key = w.GetPressedKey();
if (key != Keys.None)
{
result = key;
goto END_WHILE;
}
}
}
END_WHILE:
foreach (CvWindowEx w in windows)
{
w.EndKeyCheck();
}
return result;
}