Search code examples
c#.netvbams-access

How can I specify processor affinity?


I have an application that's having some trouble handling multi-processor systems. It's not an app that I have a particular affection for modifying and would like to avoid it if possible. However, I'm not above modifying the code if I have to. The application is written in VBA (and hence my inclination to avoid touching it).

We've noticed that the application seems to run pretty smoothly if we set the processor affinity to a single processor using task manager, only manifesting instability when processor affinity isn't set.

I know that I can specify the processor affinity of a task using .NET and as such, there lies a possibility of me writing a shell application that could be used to run legacy applications with a specified processor affinity, does anyone have any experience with this and can throw out some ideas as to headaches I'm likely to run into with this approach?

The other question is: Is it in fact possible to modify the core VBA product to handle its own processor affinity? I've never had to handle this with any of my applications natively so this (at this point in time) is completely outside my realm of expertise.

Thanks in advance


Solution

  • One way you can do this is with the Windows Application Compatibility Toolkit.

    You give it a way to identify your application (e.g. by .exe location), and then it allows you to specify a number of tweaks. Processor affinity is one of them. It creates a database that holds all your tweaks.

    It's per-machine, so it's not a good solution for a widely-distributed application, but if this application only has to run on one machine, it'll save you having to change the code.