Memory doesn't care what thread it runs on, it's more likely that you aren't passing the right parameters. You will need to figure out how the function you are calling works, so you can pass it the right parameters. Looking in to MS/Windows "__stdcall" may help.
Mod Edit (Google Translate): I can be sure that my parameters are correct, because it can work successfully, I suspect that when I call the call another thread or the main thread is also called, so the conflict, and then the game will terminate abnormally, I tried to use the method of dll injection SetTimer to implement, no problem
But with the cheat engine I do not know how to change