> >ON ESCAPE ThisForm.QuitProcess = .T. > >ThisForm.QuitProcess = .F. > >BEGIN TRANSACTION > >DO WHILE NOT ThisForm.QuitProcess > * here, we do stuff like calculations, record inserts >ENDDO > >IF ThisForm.QuitProcess > ROLLBACK >ELSE > COMMIT >ENDIF >>
LOCAL TestForm AS FormWithLengthyProcess LOCAL Catcher AS Exception m.TestForm = CREATEOBJECT("FormWithLengthyProcess") m.TestForm.Show() TRY SET ESCAPE ON ON ESCAPE ERROR "Interrupted" m.TestForm.LengthyProcess() CATCH TO m.Catcher WHEN m.Catcher.ErrorNo = 1098 AND m.Catcher.Message == "Interrupted" m.TestForm.Aborted = .T. CATCH TO m.Catcher MESSAGEBOX("Something bad happened while process was running") FINALLY ON ESCAPE ENDTRY MESSAGEBOX("Process ran to " + TRANSFORM(m.TestForm.DisplaySomething) + " and it was " + ; IIF(!m.TestForm.Aborted,"not ","") + "aborted") m.TestForm.Release() DEFINE CLASS FormWithLengthyProcess AS Form DisplaySomething = 0 Aborted = .F. PROCEDURE LengthyProcess This.DisplaySomething = 100000 This.Aborted = .F. DO WHILE !EMPTY(This.DisplaySomething) WAIT WINDOW TRANSFORM(This.DisplaySomething) NOWAIT This.DisplaySomething = This.DisplaySomething - 1 ENDDO WAIT CLEAR ENDPROC ENDDEFINE