Recognise closing of form in X++ code.

I have a class that opens a form. I would like the user to be able to edit some records using the form and when the user closes the form for the code in the class to continue running.

Is there are way of doing this?

Yes james, you can overrride the canclose method in that form and again call that class in canclose, so by this you can control the form using canclose.

Have tried what you said but have used the close method instead of the canclose. Seems to work.

I am not familiar with the canclose method, is there an advantage to using canclose?

Canclose is almost similar to close. but canclose is the first method called when user close the form this is the reason why i told you to write in it.