views:

100

answers:

2

I have a storyboard that seems to stop randomly by itself, I cannot for the life of me figure out why.

It seems to stop and random intervals.

private void CreateStoryboard(int from)
    {
        int? targetTo;
        Duration dur;
        targetTo = 150;
        dur = 150;

        Int32Animation element = new Int32Animation();
        element.From = from;
        element.To = targetTo;
        element.Duration = dur;
        Storyboard.SetTargetProperty(element, new PropertyPath(CurrentFrameProperty));
        _filmstripStoryboard = new Storyboard {SpeedRatio = this.FrameRate};
        _filmstripStoryboard.Children.Add(element);
        _filmstripStoryboard.Completed += new EventHandler(FilmstripStoryboard_Completed);
         _filmstripStoryboard.Begin(this, true);
    }

As you can see im affecting the custom "CurrentFrameProperty" DP, which has a callback method that I print out the current frame.

For some reason, and I have just no idea why, the storyboard just stops. The completed event does NOT get fired, and the callback method stops getting called.

And I am sure that I am not calling stop() anywhere.

If anyone has had this issue or can help me debug it, I would be very grateful.

A: 

Your code should work. I am not sure what the SpeedRatio=this.FrameRate does, but you can easily test your code with that piece removed. My best guess is that some other piece of code is affecting your DpendencyProperty, and that multithreaded code is biting you.

Dabblernl
Can you think of a way to debug this?
Mark
Well for starters, isolate this piece of code, so that you can be 100% sure that it works if no other factors can influence your DP.If so, add the behavior of your full project by one feature at a time until you can reproduce the problem. Sounds pretty standard, eh? ;-) Good luck!
Dabblernl
Is there a way to check if the storyboard (or animation) gets disposed of? I know of the IDispose interface, but does that get called if the object simply gets set to null?
Mark
I am sorry, I am out of my depth here. Seeing that noone reacted to this question and your previous one I just wanted to let you know that I think that the problem is not located in the piece of code you showed us.
Dabblernl
Well I just put Console statements in the Destructors of the objects holding the Storyboards, and they are getting called WAY to early. I guess I need to figure out why they are getting set to null/destructed
Mark
good luck and post back when you think you find something of general interest!
Dabblernl
A: 

It was the deconstructors! My objects with a reference to the storyboards and animations were getting destroyed, so the animation just looked like it froze up.

user error :)

Mark