Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Way to tell a loop to stop
Message
 
À
28/12/2004 20:15:41
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
00972763
Message ID:
00972892
Vues:
15
>I have a loop which is executing a bunch of processes. I would like to drop on the form a button to stop it. Basically, what would be the best approach to have the button accessible during the process so I could stop what is being executed?

The easiest way to do this is to make sure you have DOEVENTS sprinkled through your code to give your form control to handle the Cancel button or whatever. You then need a flag in the executing code to make sure to let the process know that it's been cancelled and exit out after the next step/task.

Using a timer roughly has the same effect but is maybe a bit more work. In both cases you rely on the executing process yielding often enough to allow you to click the button. If you're stuck in the middle of some command though (like a long SQL command or report) this may not be possible.

+++ Rick ---
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform