Mange Excel Interop in aborted threads RRS feed

  • Question

  • My program uses the excel interop.  I need the application object to be a global variable and initially I had

    Public oXl As New Microsoft.Office.Interop.Excel.Application

    I didnt like how excel.exe lingered so I changed the public declaration to

    Public oXl As Microsoft.Office.Interop.Excel.Application

    and create a new excel object from within my threaded run sub.

    oXl = New Microsoft.Office.Interop.Excel.Application

    When the thread ends normally I garbage collect and the excel.exe goes away.  I can restart the thread many times with no issue.


    The process inside of the run sub can take a long time, so i want to add the ability to stop.  When I use the thread.Abort it looks like the reference to the excel.exe is lost.  about 3/4 time the excel.exe also ends during this process.  The 1/4 time that the excel.exe remains open, the link to the the application is completely removed.  When I close the application it remains.  The action is the same whether or not I garbage collect after the abort.  This action is the same whether or not I use a Try/Catch for System.Threading.ThreadAbortException

    Does anyone have a solution?

    Tuesday, February 12, 2013 2:24 PM


All replies