Information générale
Catégorie:
The Mere Mortals .NET Framework
Hi Matthew,
How do you call the calculation from the Ok button? Do you use delegates?
If you run the calculation on the same thread as the UI, I doubt that you can cancel it, even if you do Application.DoEvents. Your cancel will be called after the calculation is done, because DoEvents is queueing all the requests and processes them sequentially.
My suggestion is to use delegates for the time consuming calculation.
I ran into a similar issue but in my case I used async callback with delegates.
From the main UI I instantiate an object that handles the calculation,and inside the object I invoke the delegate asynchronously.;
If the user wants to cancel the process, what I do is, I keep a reference to the asynccallback in the calculation handler class and call AsyncWaitHandle.Close() on it. For me, this trick did it.
Hope it helps,
Vlad
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement