Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Maybe multithreading...?

Posted on 1998-09-10
5
Medium Priority
?
180 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 300 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

782 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