Link to home
Start Free TrialLog in
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.
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

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.
Avatar of 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
Avatar of LeeLiam
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.
.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.
Avatar of 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
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LeeLiam

ASKER

Perfect. Thanks.
Avatar of LeeLiam

ASKER

Exactly what I needed.