Avatar of LeeLiam
LeeLiam
 asked on

Set processor affinity with vb.net

We have a VB.Net application using an Access database. We have added several background tasks. This seems to work fine on most computers. However, one customer said all of their Core i5 and i7 computers were experiencing slowness. Finally, they said they solved the problem by setting the processor affinity from all cores to just one core. This seems counter-intuitive to me. It seems fewer cores would cause more slowness.

Is it possible this is a good solution? If so, what is the best way to program the application to use one core?

Thanks.
Visual Basic.NETC#

Avatar of undefined
Last Comment
LeeLiam

8/22/2022 - Mon
Jacques Bourgeois (James Burger)

Access is not designed for multiple simultaneous accesses. It cannot process a request from one of the cores while another one is using it. It just pile up requests in queue and process them one after another.

So using an Access database with multiple cores gives you no advantage, but bogs down the whole thing because of the extra overhead encountered by the different cores to manage concurrency on the database access.

Many programmers think that 64-bit, multicore, multithread and asynchrone methods solve all the problems. But as long as an application is dealing with another one that was not built with these in mind, you often make things worse by using a new technology with older software.
ktaczala

Try this create a startup app that calls your app thru process start:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim myProc As Process = Process.Start("Path_to_application\myapp.exe") : myProc.ProcessorAffinity = CType(1, IntPtr) : End
me.close
    End Sub
' the 1 is the processor to use 1=CPU0, 2=CPU1, etc
LeeLiam

ASKER
Does this mean there is no way to put something in the code of the original VB.Net application that can set the processor affinity when it is launched? It seems strange the .Net Framework doesn't have something to handle this.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Jacques Bourgeois (James Burger)

.NET can, but the Access database engines, either JET or ACE are not multicore, and when you work with Access, you are working with that engine. And as far as I know, a unique engine processes all the calls on a given computer.
LeeLiam

ASKER
Maybe I was misunderstood. Is it possible, using VB.Net code, to set the processor affinity from the default of all cores so the application will use only a single core?
ASKER CERTIFIED SOLUTION
Jacques Bourgeois (James Burger)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
LeeLiam

ASKER
Perfect. Thanks.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
LeeLiam

ASKER
Exactly what I needed.