Controlling FG & BG timeslicing

I need to control the way Windows allocates processor time to the foreground and background tasks from within VB6. The foreground tasks are getting too much processor time causing the background tasks to barely do their thing. Is there a way to do this in VB6 using API calls or whatever?
kenvcAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mark2150Commented:
Sprinkle DoEvents inside your loops and in your code to cede some time to other tasks. Do Async data queries.

M
0
mcriderCommented:
Be careful when using doevents...

Any time you temporarily yield the processor within an event procedure, make sure the procedure  is not executed again from a different part of your code before the first call returns; this could cause unpredictable results. In addition, do not use DoEvents if other applications could possibly interact with your procedure in unforeseen ways during the time you have yielded control.

The doevents should be used in both the foreground and background applications...

Cheers!
0
kenvcAuthor Commented:
This method will not work because it assumes I have access to the source code of all the programs that could be running on my computer.

I need a solution (probably an API call) that can be called 1 time from VB6 that permanently changes the way Windows allocates cpu usage on all FG and BG tasks globally for ALL programs. ie. change from 90%/10% to 50%/50% or whatever.

It can be a permanent change or it can be a change that just lasts until the system is restarted... that part does not matter.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mark2150Commented:
That call doesn't exist.

If you put the DoEvents in your own code you should see an immediate performance boost. Try it and see. The other code will not hog the resources because they are the BG tasks. You get preference because you're the FG task.

M
0
mcriderCommented:
I think what you're looking for is the SetPriorityClass and the SetThreadPriority APIs.

SetPriorityClass is defined here:
http://msdn.microsoft.com/library/psdk/winbase/prothred_9z1v.htm

SetThreadPriority is defined here:
http://msdn.microsoft.com/library/psdk/winbase/prothred_9f5l.htm

If you have access to assembly (MASM) you can use Set_Time_Slice_Priority defined here:
http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/ddkdoc/win95ddk/kernel_98vq.htm


Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcriderCommented:
This is really bizzare on microsofts part... if you click on the references I gave you above, you get the message "this page has moved"...

However, if you highlight the URL and copy it to the clipboard and paste it to the browser address line, or type the URL in manually, you get the page...

Really weird!


Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.