1

I would like to ask what method to update GUI is better for my scenario. I would like to manipulate (move) multiple controls from point to point based on the input from user's touches.

I know a few difference way to do it. Dispatcher Timer & Timer. (What's the difference between them?) BackgroundWorker. Storyboard & BeginAnimation Method.

Which of these method is generally recommended to use in term of memory and resource saving and simpler to code?

Thank you!

Jose Luis
  • 3,307
  • 3
  • 36
  • 53
Sydnal
  • 71
  • 2
  • 7

2 Answers2

0

I suppose these 3 SO QA should help u understand all the differences:

DispatcherTimer vs a regular Timer in WPF app for a task scheduler

Comparing Timer with DispatcherTimer

WPF BackgroundWorker vs. Dispatcher

Community
  • 1
  • 1
S2S2
  • 8,322
  • 5
  • 37
  • 65
  • Thank you! I certainly understood more, however I'm still unclear on the concept of backgroundworker. Will it be called multiple time like how DispactherTimer call a method on a certain interval? Thank you. :) – Sydnal Oct 20 '11 at 05:16
  • No only once. Backgroundworker has a DoWork() eventhandler which once attached can be only executed explicitly when the programmer wants it to with a call to backgroundworker.RunWorkerAsync(). – S2S2 Oct 20 '11 at 05:22
0

Apart from the link given by Vijay, a common concept that is vital in WPF application while you manipulate visuals is Dispatcher

In short, a Dispatcher is a message queue gateway manager to the UI, that receives delegates and prioritises them to execute on the given thread. In WPF, UI thread is STA. Also any visual created on UI thread has a thread affinity which means if you are performing any multi threaded functionality (for faster performance) then when it comes to manipulating those visuals such as updating their values, increasing / deacresing their size, focusing them, transforming them etc. has to be done using the UI Dispatcher.

Now back to your situation, when you want to move items, translate transform animation is a good option.

Hope this helps you in correct direction.

WPF-it
  • 19,625
  • 8
  • 55
  • 71