Wednesday 7 December 2011

Lost Exceptions inside DispatcherTimer Tick Handler

I have been using LittleWatson in my WP7 apps to catch unhandled exceptions and report them back to me by email if the user so chooses.

However, I found that I had a stack trace on Marketplace but no report.  I thought it might be because the user hadn’t sent the message, so instead forced the exception I was guessing I had an OutOfMemory exception, as the stack trace had a LoadJpeg call in it for a 1600x800 image.

So I added this line:

throw new OutOfMemoryException()

To my surprise, LittleWatson didn’t catch it.  So I threw the same exception at various other places in my code, and LittleWatson did catch it.

What I discovered (In 7.10.7720.68 at least) is that OutOfMemoryExceptions are swallowed, and appear to terminate your application inside a DispatcherTimer Tick Handler.

No comments:

Post a Comment