General information
Category:
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
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only