M
mcm
For my Windows CE 5.0 App (using C# in Visual Studio 2005) I have to create several images (on the fly) and play them back as an animation.
I've created an "Animation Control" which holds an array of images (usually about 18 images) and uses a timer to show them via "DrawImage".
This control loops through the array of images on each counter tick per the following:
private void timerAnimation_Tick(object sender, EventArgs e)
{
if (animationImages.Length <= 0) // no images in the array
return;
if (++nCurrentImageRef >= animationImages.Length)
nCurrentImageRef = 0;
// draw the current image
// gControl is the Graphics object for this control
gControl.DrawImage(animationImages[nCurrentImageRef], ClientRectangle.Left, ClientRectangle.Top);
}
My problem is that this animation runs smoothly for a couple hundred timer ticks, pauses for a few seconds and then continues where it left off.
These pauses are typically for 3 or 4 seconds and they occur somewhat randomly. Is this due to garbage collection or due to my "DrawImage" approach?
I've used other timers in this application (just to test what's going on) and they don't experience these same "pauses" - just this one.
Thanks.
I've created an "Animation Control" which holds an array of images (usually about 18 images) and uses a timer to show them via "DrawImage".
This control loops through the array of images on each counter tick per the following:
private void timerAnimation_Tick(object sender, EventArgs e)
{
if (animationImages.Length <= 0) // no images in the array
return;
if (++nCurrentImageRef >= animationImages.Length)
nCurrentImageRef = 0;
// draw the current image
// gControl is the Graphics object for this control
gControl.DrawImage(animationImages[nCurrentImageRef], ClientRectangle.Left, ClientRectangle.Top);
}
My problem is that this animation runs smoothly for a couple hundred timer ticks, pauses for a few seconds and then continues where it left off.
These pauses are typically for 3 or 4 seconds and they occur somewhat randomly. Is this due to garbage collection or due to my "DrawImage" approach?
I've used other timers in this application (just to test what's going on) and they don't experience these same "pauses" - just this one.
Thanks.