exception?

  • Thread starter Thread starter df g
  • Start date Start date
D

df g

A subroutine is nested many levels deep in the call stack, and is
looping on a mathematical calculation. If the user clicks a command
button called cmdStop, you want the loop to stop executing and return
control to the top-level procedure, just after the call to the next
lower level. How would you do that?
Thanks all!
 
As you want to response user's action. You possibly want to create another
thread to do the calculation, so when it is busy in the loop, your UI
thread can still keep the button alive.

To go out of the loop, as your subject said, you can throw an exception and
handle it on the top-level. In the loop, you might want to add code to
check whether the user clicked the 'stop'.

Thanks
 
Back
Top