Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Tue, 8 Jul 2008 16:12:07 -0400,    group: microsoft.public.dotnet.framework.compactframework        back       


Timer-based Animation with g.DrawImage Gives Random Pauses   
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.
date: Tue, 8 Jul 2008 16:12:07 -0400   author:   mcm

Re: Timer-based Animation with g.DrawImage Gives Random Pauses   
It's highly likely to be a GC issue, though RPM would tell you for certain 
(and quite quickly).  We don't see enough of your code to know where any GC 
issues might lie though.

-Chris


"mcm"  wrote in message 
news:e6%23slbT4IHA.1192@TK2MSFTNGP05.phx.gbl...
> 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.
>
>
date: Tue, 8 Jul 2008 16:08:34 -0500   author:   Chris Tacke, MVP ctacke.at.opennetcf.dot.com

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us