SoFunction
Updated on 2025-04-11

Solve the problem of multithreading errors in easy language

log_Content

Recently, I was writing software to the client and found that I had not found any errors. However, the client's software went through multiple threads and failed to find the problem. It took me a long time to find the solution. It turned out to be a CPU problem. Multithreading has problems with dual-core CPU affinity. Now I have found a solution to the problem. By the way, I will record it. Maybe some friends encounter the same problem, so I can refer to it together.

DLL command:

. Version 2

.DLL command SetProcessAffinityMask, integer type, , , expose, set CPU affinity Process handle Return CPU number

. Parameters hProcess, integer type

. Parameters hProcess, integer type

.DLL command SetThreadAffinityMask, integer type, , , expose, set CPU affinity Thread handle

. Parameters hProcess, integer type

.Parameter Mask, integer type

.DLL command GetCurrentProcess, integer type, , , public, gets a pseudo-handle to the current process. Generally, it is -1

.DLL command GetCurrentThread, integer type, , , public, gets a pseudo-handle to the current thread. Generally, it is -2

Just put the following code into the Easy Code to start:

SetProcessAffinityMask (-1, 1)

The above is all about solving the problem. Thank you for your support.