Forcing an app to run single core only?

前端 未结 3 1188
萌比男神i
萌比男神i 2021-01-21 03:26

I have this strange issue with some third party DLL\'s. The third party provider references some open source DLL\'s that have a memory exception whenever I try to use a certain

相关标签:
3条回答
  • 2021-01-21 04:09

    Personally I'd drop that functionality (you said this is an option). Multi-threading is a very touchy subject and it's obvious the 3rd party DLL isn't written very well.

    You say the issue doesn't appear if you run it on a single core but not seeing a problem doesn't mean you don't HAVE a problem (and threading issues are only rarely seen anyway), so chances are your product might fail because of this every once in a while.

    0 讨论(0)
  • 2021-01-21 04:09

    I once had some strange problems when referencing DLLs that were 32-bit but the .NET application was built as 64-bit. Since you mentioned that it doesn't happen on the single core machines, I'm assuming they're 32-bit and the multi-core machines are 64-bit?

    The only difference was I was getting a BadImageFormatException, which you didn't mention. Anyway, the way I solved it was to set the "Platform target" of my application to x86 and everything worked after that.

    0 讨论(0)
  • 2021-01-21 04:14

    What you want to do is achieved by using Process.ProcessorAffinity. Note that this will make your entire application run single-core.

    Edit: your problem may be a result of the DLL expecting to have single-processor affinity, but it can also be a threading issue (e.g. race condition) that is very unlikely to happen when you only have a single core. If the last one is true, you can't really do anything except cross your fingers and pray (and maybe consider dropping the functionality to keep your application stable).

    0 讨论(0)
提交回复
热议问题