Knowledge Base Nr: 00279 getasynckeystate.cs - http://www.swe-kaiser.de

Downloads:

c#: GetAsyncKeyState() verwenden / langwierige operation mit ESC abbrechen

  
[System.Runtime.InteropServices.DllImport("User32.dll")]
private static extern short GetAsyncKeyState(System.Int32 vKey);

private void DoCheck()
{
foreach (...)
{
short keyEsc = GetAsyncKeyState((int)Keys.Escape);
if (keyEsc != 0)
break;

...
}
}