Here I will post problems I and my colleagues met and solutions we found.

Thursday, October 11, 2007

Timers

Experimenting with timers in WPF I found some interesting differences from Windows Forms.

  1. We cannot use timer from Windows.Forms namespace, which leaves us to Timer from System.Timers or System.Threading namespaces.
  2. Both these timers execute their events/delegates in separate thread, from ThreadPool, which means we cannot directly operate with controls now. Again this is opposite to Windows Forms timer.
  3. Timer from System.Timers object has SynchronizeObject property of ISynchronizeInvoke interface type. However, WPF controls do not support this interface so we cannot use it. Again, this is not the same as for Windows Forms.
  4. WPF controls do not have Invoke methods as Windows Forms controls.
  5. What we can and should use is Control.Dispatcher.Invoke method.

No comments: