Solved

Maybe multithreading...?

Posted on 1998-09-10
5
153 Views
Last Modified: 2010-04-30
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.
0
Comment
Question by:Upland
5 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 1434028
How are you animating the task? I use a picture clip control and a timer to change the pictures on a regular basis.
0
 

Author Comment

by:Upland
ID: 1434029
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
 
LVL 6

Expert Comment

by:clifABB
ID: 1434030
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
 
LVL 12

Accepted Solution

by:
mark2150 earned 150 total points
ID: 1434031
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
 

Expert Comment

by:Aim
ID: 1434032
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now