# Execution must freeze between animations (C# WPF)



## MrSeanKon (Dec 5, 2012)

Well pressing the button both cards are animated. Sometimes it is necessary, but other not.
How can I freeze the code execution? 
I mean that during 2 of Clubs animation the King of Hearts "must wait" for completation and then starts.
One solution I think is by adding a timer but this is not supported in WPF.
Any other ideas?
Using threads, but this is a bigger headache?


----------



## FordGT90Concept (Dec 5, 2012)

It'll be something in the form Dispatcher.  I've never done much with WPF animations so I can't offer much more than that.


----------



## Kreij (Dec 5, 2012)

Use the BeginTime property of the DoubleAnimation class to delay the animations start.


----------



## MrSeanKon (Dec 5, 2012)

Before testing your solution Kreij I made a code based on Ford's idea.
But needs improvements!
It is impossible to create different timers & timer event handlers for each card. I think it is simple for both of you to rewrite a smaller code


----------



## FordGT90Concept (Dec 5, 2012)

I think WPF all runs on one thread--the dispatcher.  The system works by invalidating a control and then it redraws that control and all children in the next refresh.  If there's nothing invalidated, it keeps displaying what was there previously.  This is what allows WPF to be resource friendly (only updates when necessary), flexible (it can draw literally anything), and fast (runs mostly on GPU).


----------



## MrSeanKon (Dec 5, 2012)

Kreij means *something like this* but the problem is XMAL usage. To be more specific sometimes the same cards must be animated in order (separately during deal) and other times not (when you pick cards from green baize all grabbed cards must be animated simultaneously).
This cannot be written in XMAL. Or am I wrong? 
That's why I uploaded the attachment on my previous post.
BTW the thread is continued *==> link <==* please don't post here anymore.


----------

