473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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
Jun 27 '08 #1
4 2102
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.
Jun 27 '08 #2
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
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.
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.
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.
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.
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
Jun 27 '08 #3
On May 30, 4:17*pm, Jon Jacobs <JonJac...@discussions.microsoft.com>
wrote:
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.
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.

Jun 27 '08 #4
>Or your animation routine is a function of time, so
>given an arbitrary time generate the appropriate frame.
Exactly
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: J. Baute | last post by:
I'm caching data in the Application object to speed up certain pages on a website The main reason is that the retrieval of this data takes quite a while (a few seconds) and fetching the same data...
3
by: Amit Dedhia | last post by:
Hi I am developing a Dot net application (involving image processing) on a uni processor. It works well on my machine. I then take all my code on a multi processor, build and run the application...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
20
by: Peter Oliphant | last post by:
How does one launch multiple forms in an application? Using Photoshop as an example, this application seems to be composed of many 'disjoint' forms. Yet, they all seem somewhat 'active' in...
6
by: Josef Brunner | last post by:
Hi, I published my application (VS 2005) and am now trying to install it when I get this error message. It worked before...even on a different machine. Here is the detailed description: ...
9
by: jeff | last post by:
Hi All. I realize that when my Deployed winforms application starts, Windows needs to load the .net 2 framework before control is given to my application.... Is there anyway to either ... -...
3
by: asadikhan | last post by:
Hi, I have written a windows application with a GUI (let's call it MENU). I own the code for this application and have access to it. We have another application that is a third-part windows...
2
by: Michael Kalika | last post by:
Hi, We have developed a VSTO 2005 Excel application and we would like to leverage ClickOnce deployment mechanism for distribution of this application. How can we do that? I was digging in MSDN...
0
by: Tifer | last post by:
Hello, I am building my first .Net Application. The first couple of Publish and Installs I did went fine. But after a couple of builds, I get a modal dialogue box error every time upon trying...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.