Best practice in this situation?

Posted by Steve on Stack Overflow See other posts from Stack Overflow or by Steve
Published on 2010-04-04T21:09:32Z Indexed on 2010/04/04 21:13 UTC
Read the original article Hit count: 433

My Delphi program relies heavily on Outlook automation. Outlook versions prior to 2007-SP2 tend to get stuck in memory due to badly written addins and badly written Outlook code.

If Outlook is stuck, calling CreateOleObject('Outlook.Application') or GetActiveObject ... doesn't return and keeps my application hanging till Outlook.exe is closed in the task manager.

I've thought of a solution, but I'm unsure whether it's good practice or not.

I'd start Outlook with CreateOleObject in a separate thread, wait 10 seconds in my main thread and if Outlook hangs (CreateOleObject doesn't return), offer the user to kill the Outlook.exe process from my program.

But since I don't want to force the user to kill the Outlook.exe proccess, as an alternative I also need a way to kill the new thread in my program which keeps hanging now.

My questions are: a, Is this good practice b, How can I terminate a hanging thread in Delphi without leaking memory? Is there a way?

© Stack Overflow or respective owner

Related posts about outlook

Related posts about delphi