How to STOP a CPU high expensive method
-
Hi guys I've got a method that is really CPU high expensive and I want to stop it when I click the mouse or press a key but , what's the best way to do this without slow the process? I've tried with PeekMessage but it takes a lot of time to stop the process after the key pressed then. Thanks in forwarding DrPi
-
Hi guys I've got a method that is really CPU high expensive and I want to stop it when I click the mouse or press a key but , what's the best way to do this without slow the process? I've tried with PeekMessage but it takes a lot of time to stop the process after the key pressed then. Thanks in forwarding DrPi
You can try multithreading. You run your CPU expensive code in the second thread and you can kill it from your main (GUI) thread. The best way to do this is to poll regurlaly for the exit command. See here[^] for more information on this. Behind every great black man... ... is the police. - Conspiracy brother Blog[^]
-
You can try multithreading. You run your CPU expensive code in the second thread and you can kill it from your main (GUI) thread. The best way to do this is to poll regurlaly for the exit command. See here[^] for more information on this. Behind every great black man... ... is the police. - Conspiracy brother Blog[^]
-
Thanks guy I was suposing that "your solution" is the ONLY correct solution. I'll have to convert my code to a thread. Dr.pi
I only know of 2 solutions. This worker-thread solution and the
::PeekMessage()
solution. You'll have to choose the one based on your needs. For example if your task is running often or the entire time, you should not even consider the::PeekMessage()
solution. Behind every great black man... ... is the police. - Conspiracy brother Blog[^]