Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Maybe multithreading...?

Posted on 1998-09-10
5
Medium Priority
?
176 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Suggested Courses

670 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