Opengl Crash when ProcessMessages used

I’m getting crashes using opengl under WinXP and writing in Delphi. We are implementng an interruptible zoom feature for a mechanical CAD package. We are displaying a large number of primitives for a mechanical object (ie > 300000) so it can be quite slow to draw.

The interruptible bit works like so - you press zoom-in 5 times and the application will draw the structure quickly (ie just the outline) the first 4 times (at the appropriate magnification) and then in full the next time.

The application is not multithreaded, so we currently use ProcessMessages/PeekMessage at certain points in the rendering loop to determine if any relevant keystrokes/left mouse button is used.


My problem is this :
If we break out of rendering immediately (ie using ProcessMessages) OpenGL will invariably crash (and I can’t trace into it).

My question is this :
Is there some way (eg liberal use of glFinish) of making OpenGl not crash when ProcessMessages is used to break out of the rendering loop without finishing the loop as per-normal? Does it acutally crash for anyone else in similar situations