Macro Not End

I have written some code in VSTA (C#). My code is perfectly run except that the VSTA debugger never stop running.

My macro composes of one form but I normally close that form using this.Close(); expression and point it to null in very last in the main method. This macro does not relate to the threads. I am in doubt that whether the macro are still "alive" in RAM beyond the code instruction. Moreover, which is the cause of the problem, my fault, SolidWorks error or VSTA error.

I have tried to change the ending way by using System.Environment.Exit(); The debugger stop running properly but in real using (.dll running), I have got a dialog appeared.

I also tried to trace the step of running by using MessageBox.Show(); expression. The result appeared as if the macro run to the end of last line without any error occur.

As you can obviously see that the this try..catch statement are the largest statement entirely wrapping most thing in main method. After the Message Box disappeared, the same problem occurs again.

I have found the answer in https://forum.solidworks.com/message/98903#98903. So, I assume that my macro will not cause memory leak.

Message was edited by: Pranithan Thamcharoenporn

Sorry about my mistake.. I have tried the suggestion above but I have forgetten delete the line System.Environment.Exit(0); So, the problem is still NOT solved.

Message was edited by: Pranithan Thamcharoenporn

SolidworksApi macros