Maybe multithreading...?

In VB5 I would like to create a small animation by rotating
bitmaps - a bit like the meteor shower in Netscape or the
globe in IE. Under normal operation this is obviously
quite uneven - depending on what else is happening in the app.

I was wondering if I could perhaps set a task running on a different thread as it requires no user intervention. It just starts... and after a certain task is completed it stops.

Or maybe there is another way to animate it more smoothly.
UplandAsked:
Who is Participating?
 
mark2150Commented:
Actually your smallest interval is 55mS (1/18.2).

There are no reliable highspeed timers available in the PC as there is no hardware that will generate the timing reference. The master clock tick is 18.2 per second and even if the timer has units of milliseconds, is joke as the system can't produce a tick at that speed.

Persistence of vision gives the illusion of smooth motion at about 18-20Hz. If your timing loop based on the 18.2/sec ticker is jerky then your graphics are spatially too distinct. You'll need to add "tween" pictures. Test this when *NOTHING* else is running.

My guess is that your main code is an execution hog. Try putting DoEvents here & there in your loops to give the rest of the code time to run. Also put a .Refresh after you picture updates. This will force a repaint *now* instead of waiting for the next execution timeslice.

You may find that to get enough execution to your animation that you degrade the performance of the real meat of your app. This would be, to me, an unsat tradeoff as I am more concerned about thruput than pretty. In the old drag racing days they used to say that the paint job don't make it go no faster!

M

0
 
mark2150Commented:
How are you animating the task? I use a picture clip control and a timer to change the pictures on a regular basis.
0
 
UplandAuthor Commented:
Yes.. I have tried using a timer but the smallest interval you can use is about 60 due to the fact that VB uses 'ticks'... this in itself is not too bad a speed but I still have the same problem with jerkiness if there is a lot of other stuff going on. An alternative is to set up your own loop and access the clock directly via an API call to get a smaller interval than 60. I still feel a separate thread is the only way to go with this.
Maybe I'm just a pedant?   :o)
0
 
clifABBCommented:
You could create a custom control (which would run as a separate task).

Also, if you need a high frequency timer, Mabry (www.mabry.com) has one.
0
 
AimCommented:
If you need a high performance timer, the CCRP has one that is free.  I have not used it myself, however it is free and their other controls are quality work.  The address is:

http://www.mvps.org/ccrp/
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.