What excactly are you trying to achieve? Is it that once the user has pressed the escape key, you want the application to terminate as soon as possible? Or do you have a longish OnPaint method which you want interrupted when the escape key is pressed? The first would be much easier. The second I think cannot work without polling for the EXIT variable within the OnPaint procedure everywhere it could be interrupted, and even then I'm not sure it could work. A call to Application.DoEvents won't help cause in OnPaint you're right within handling the windows message queue and have to finish the loop anyway. The keyboard action only puts a message to the end of your form's message queue, which will not be processed before you leave the OnPaint method. Either you do some crazy unmanaged subclassing, or you split your painting logic into "atomic" operations which you instigate (via this.BeginInvoke) from a different thread. In this thread you can capture the EXIT flag set by the main thread via the escape key and if it's true stop pouring BeginInvoke(PaintNextPart) delegates to the main thread. You need a little more then, of course, and a firm grip of threading and locking mechanisms, or you'll freeze your form.