I tried writing another Outlook extension tonight. This time, a desktop widget to display a dashboard-style at-a-glance view of how busy I am (based on my Microsoft Outlook task list).
I wrote it to run in the background, and update itself once a minute. This raised an interesting question – what to do with the handle to Outlook.
Getting the handle to Outlook is probably the slowest bit of the app, so I don’t want to do this every minute. But caching a handle and reusing it ad-infinitum probably isn’t safe – what if Outlook is closed or restarted, (or… whatever happens when Windows hibernates?) while the widget app is running? Would the widget hold locks on the Outlook data file and cause a closing Outlook to hang? Or would the widget just fall over the next time it tried to use an invalid handle to the Outlook object model?