473,748 Members | 3,585 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Application.Rai seIdle

In VB I am doing an animation via Application.Idl e.

My idle routine is:
Private Sub Form1_Idle(ByVa l sender As System.Object, ByVal e As
System.EventArg s)
Draw()
Application.Rai seIdle(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.DoE vents 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 2123
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...@disc ussions.microso ft.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
3291
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 from the "cache" hardly takes any time A basic pattern used to get the data from disk, or from cache is this data = getDataFromCache("mydata" if data = "" the data = getDataFromDisk( storeDataInCache(data, "mydata" end i
3
3149
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 there. There is performance degradation. The usual performance of the application on MP machine is better than that of uni processor machine. But the performance of MP degrades when it comes to the multi-threaded part of the application. I am...
6
20085
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 quite a few words in this post but the questions are actually quite similar and should be fairly quick to answer ... (1) What is Happening with the Threads
20
2718
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 contrast to one of them always being 'modal' (e.g., if you are moving over a picture the 'Info' form will update the (x,y) screen location in realtime even if not the selected form. Also note that this example implies the various forms can communicate...
6
25065
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: PLATFORM VERSION INFO Windows : 5.1.2600.131072 (Win32NT) Common Language Runtime : 2.0.50727.42
9
2988
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 ... - preload the .net 2 framework (windows startup or whatever) - splash a screen ... application loading ... please wait ... type of
3
2692
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 application with a GUI interface as well (let's call it BASE). I don't have access to the code of this application. This application has hooks through which other applications can be called. I have defined a hook in this application which bring up...
2
4544
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 for VSTO & ClickOnce documentation and did not find anything. I've noticed that there is an option to publish the project, but when I do that and then run the application from Web it throws us security errors like:
0
5252
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 to install using the setup.exe. Title is "Cannot Start Application" and it says: ==================== Cannot download the application. The application is missing required files. Contact application vendor for assistance.
0
8823
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.