I just used ImageAnimator class for the first time. And I ran into a problem pretty quickly.
First, OnFocusChanged eventhandler will be fired from another thread handled by ImageAnimator => which is not a UI thread. So any UI operations are called in the event handler, you need to use Control.Invoke to call back into UI thread.
Second, every time OnFocusChanged is called, it will make a lock using ReaderWriterLock. This worked fine until I made a callback using Control.Invoke. The deadlock appeared. I tracked down and found that there is one PictureBox using ImageAnimator as well and it is trying to Dispose itself which called ImageAnimator.StopAnimator on UI Thread. StopAnimator will try to get a writer lock which my OnFocusChanged has a reader lock on this. The problem is that OnFocusChanged will push a message into UI thread to update my image. But the message is after the operation to StopAnimator. So StopAnimator is waiting for lock while OnFocusChanged wait for Invoke to finish. Boom, the deadlock appeared. To solve this, easy, just change Control.Invoke to Control.BeginInvoke. So OnFocusChanged won't have to wait until the update part is done.