Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Application.RaiseIdle

Reply
 
Old 05-30-2008   #1 (permalink)
Jon Jacobs


 
 

Application.RaiseIdle

In VB I am doing an animation via Application.Idle.

My idle routine is:
Private Sub Form1_Idle(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Draw()
Application.RaiseIdle(e)
End Sub

I use RaiseIdle so I don't just draw one frame and wait until I wiggle the
mouse or something so it can go back to idle.

The animation is very smooth, and I get about a 1000 frames per second (fps)
This works for a while, but my application is very unresponsive and quits
after about a minute. If I run in the IDE, it quits in only 5 seconds or so.

If I add Application.DoEvents right after Draw, the app is very responsive,
but I get a stack overflow.

How do I avoid these problems?

Thanks,
Jon

My System SpecsSystem Spec
Old 05-30-2008   #2 (permalink)
Israel


 
 

Re: Application.RaiseIdle

I'm not familar with the RaiseIdle() method but it doesn't sound like
the right place to put animation code. What if the user were moving
the mouse around or clicking on the window - wouldn't that make the
idle even called less? Also it sounds like the DoEvents() is
synchronously calling your Idle method and if you're then calling
DoEvents() within then you get into circular loop.
Why not use a timer? You can probably get 30 fps reliably enough with
that. 1000 fps is pretty rediculous since a human probably can't even
see anything beyond 50 or 60 if even that.
I'm not sure how your animation is generated but you could use another
thread to create frames at some constant and reliable rate (since the
timer thread is lower priority) and then use the timer events just to
display the "correct" frame for that time.

If you really want to do more sophisticated animation you'll probably
need to use directX.


My System SpecsSystem Spec
Old 05-30-2008   #3 (permalink)
Jon Jacobs


 
 

Re: Application.RaiseIdle

> I'm not familar with the RaiseIdle() method but it doesn't sound like
Quote:

> the right place to put animation code. What if the user were moving
In other environments the Idle event has been the recommended place to put
the animation code, but apparently, in the .Net environment, the way it is
implemented is problematic.
Quote:

> the mouse around or clicking on the window - wouldn't that make the
> idle even called less?
Yes, that has an impact, slowing me down to 920 fps. Not bad at all.
Quote:

> Why not use a timer? You can probably get 30 fps reliably enough with
> that. 1000 fps is pretty rediculous since a human probably can't even
> see anything beyond 50 or 60 if even that.
Timers have other issues with respect to this kind of graphics. What I've
read recommends against them.
Quote:

> I'm not sure how your animation is generated but you could use another
> thread to create frames at some constant and reliable rate (since the
Also gotchas when doing this with other threads, according to what I've read.
I use logic in the image generaion so the motion maintains proper speed in
spite of changing fps.
Quote:

> If you really want to do more sophisticated animation you'll probably
> need to use directX.
I've been doing very sophisticated animation with OpenGL in other
programming environments. Now I am trying to port it into VB.NET. Just trying
to work through the issues for this particular programming environment.

Thanks,
Jon
My System SpecsSystem Spec
Old 05-30-2008   #4 (permalink)
Israel


 
 

Re: Application.RaiseIdle

On May 30, 4:17*pm, Jon Jacobs <JonJac...@xxxxxx>
wrote:
Quote:
Quote:

> > I'm not sure how your animation is generated but you could use another
> > thread to create frames at some constant and reliable rate (since the
>
> Also gotchas when doing this with other threads, according to what I've read.
> I use logic in the image generaion so the motion maintains proper speed in
> spite of changing fps.
I guess that's sort of what I meant but I didn't know how you
generated the frames e.g. if your animation routine is a function of
an iterator you could keep a buffer of generated timestamped frames
and then when the timer comes back lookup the closest frame based on
the current time. Or your animation routine is a function of time, so
given an arbitrary time generate the appropriate frame.
Quote:

> I've been doing very sophisticated animation with OpenGL in other
> programming environments. Now I am trying to port it into VB.NET. Just trying
> to work through the issues for this particular programming environment.
My only experience with animation is either cheesy little cycling
bitmaps using a timer or writing direct show filters in C++ which is
really more video processing than "animation" except for some simple
diagnostic image sources which had to generate frames from nothing.

My System SpecsSystem Spec
Old 06-01-2008   #5 (permalink)
Jon Jacobs


 
 

Re: Application.RaiseIdle

>Or your animation routine is a function of time, so
Quote:

>given an arbitrary time generate the appropriate frame.
Exactly
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Accessing Windows application from Web application? .NET General
Send to function wont open WinMail and attach pdf from adobe application. I know this can be accomplished by right clicking on the pdf file but I need the application to do the task. Any suggestions? Vista mail
appdata-local-Application Data-Application Data-Application Data infinitum ad nauseum. WHY Vista General
Application Error - CD MFC Application has stopped working Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46