Q:

Why is my paintBox Canvas being erased when my program is "Not Responding"?

I have written a small program using Borland's C++ builder, and along the way, everything seemed fine. My program has a map window and a table window, and when a user presses a button, a long process is started that reads in all the map and table information and then displays that.  Every time i ran it through the debugger, I had no issues. Then today, I decided to test it without running it through the debugger. To my horror, The program reads in the map information and then displays it on the paintbox canvas without a problem, but when it  loads the information for the grid, the map gets erased!!! It appears to happen during the load phase for the table. this takes about 4 seconds, and during which time, the window tells me that it isnt responding. This is when the map gets erased. Anyone have any ideas on why this is happening? Its driving me nuts, and I dont really understand whats going on under the hood here. 
UPDATE:
I have fixed the problem to some degree. I was poking around and found this: Avoiding "(Not Responding)" label in windows while processing lots of data in one lump
I added the code to run once in the middle of the data read in for the table. this fixed my problems. however, I was wondering if anyone knows why this is the case? why does my program going unresponsive cause my canvases to be erased? 

A:

Marcus Junglas wrote a detailed explanation of the problem, which affects both Delphi and C++Builder.

When programming an event handler in
  Delphi (like the OnClick event of a
  TButton), there comes the time when
  your application needs to be busy for
  a while, e.g. the code needs to write
  a big file or compress some data.
If you do that you'll notice that your
  application seems to be locked.  Your
  form cannot be moved anymore and the
  buttons are showing no sign of life.
  It seems to be crashed.
The reason is that a Delpi application
  is single threaded.  The code you are
  writing represents just a bunch of
  procedures which are called by
  Delphi's main thread whenever an event
  occured.  The rest of the time the main
  thread is handling system messages and
  other things like form and component
  handling functions.
So, if you don't finish your event
  handling by doing some lengthy work,
  you will prevent the application to
  handle those messages.

You can reduce the problem by calling Application->ProcessMessages(), while loading your map data, however I recomend using a separate thread to load the data. 

