Help!!! Cancel Dialog Box in C#

  • Thread starter Thread starter Claire
  • Start date Start date
C

Claire

Hi,

I am working in C#.
The program I am working on is querying databases.
This is done in the OK button Click event.
Sometimes, it takes a long time to search.
I would like to give the users the ability to cancel the search.
I was thinking of a pop-up dialog with a Cancel button.
When the Cancel button is clicked, the search is stopped.

If I try to show a modeless dialog as pop-up dialog, the controls on the
modeless dialog are not drawn.
I think there should be some multi-threading involved, but I cannot figure
it out.

I would greatly appreciate any help on the matter. I did not find any
example of this on MSDN, apart from a VisualC++6 sample, even though it is
a pretty common situation.

Thank you,

Claire
 
this is a very common problem and there are several ways to handle it.
The best way to solve this is just to put your slow code into a
thread. This would allow you to put up a cancel dialog which could
signal the thread to stop if a user pressed cancel.

Allen Anderson
http://www.glacialcomponents.com
 
Back
Top