1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Execution must freeze between animations (C# WPF)

Discussion in 'Programming & Webmastering' started by MrSeanKon, Dec 5, 2012.

  1. MrSeanKon

    MrSeanKon New Member

    Joined:
    Nov 14, 2006
    Messages:
    267 (0.10/day)
    Thanks Received:
    69
    Location:
    Athens in love with Anna :)
    Well pressing the button both cards are animated. Sometimes it is necessary, but other not.
    How can I freeze the code execution? :rolleyes:
    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?

    Attached Files:

    Last edited: Dec 5, 2012
  2. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    13,317 (6.34/day)
    Thanks Received:
    3,343
    Location:
    IA, USA
    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.
    Crunching for Team TPU
  3. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,881 (5.11/day)
    Thanks Received:
    5,615
    Location:
    Cheeseland (Wisconsin, USA)
    Use the BeginTime property of the DoubleAnimation class to delay the animations start.
  4. MrSeanKon

    MrSeanKon New Member

    Joined:
    Nov 14, 2006
    Messages:
    267 (0.10/day)
    Thanks Received:
    69
    Location:
    Athens in love with Anna :)
    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 :)

    Attached Files:

  5. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    13,317 (6.34/day)
    Thanks Received:
    3,343
    Location:
    IA, USA
    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).
    Crunching for Team TPU
  6. MrSeanKon

    MrSeanKon New Member

    Joined:
    Nov 14, 2006
    Messages:
    267 (0.10/day)
    Thanks Received:
    69
    Location:
    Athens in love with Anna :)
    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? :rolleyes:
    That's why I uploaded the attachment on my previous post.
    BTW the thread is continued ==> link <== please don't post here anymore.
    Last edited: Dec 6, 2012

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page