A function performs a loop that simulates some animation on a picturebox and goes on for about 15 seconds. The associated code uses an instance of a class.
If I click on a "Exit button" while the animation is on, the form unload sub is executed and it destroys the class. However, before the form itself is unloaded, control is returned to the plotting function and because the classes have been destroyed it crashes the program
I have tried various tricks yet to no avail.
I could disable the Exit button while the animation is on, but I assume there must be some cleverer solution.
If I click on a "Exit button" while the animation is on, the form unload sub is executed and it destroys the class. However, before the form itself is unloaded, control is returned to the plotting function and because the classes have been destroyed it crashes the program
I have tried various tricks yet to no avail.
I could disable the Exit button while the animation is on, but I assume there must be some cleverer solution.