Alphadan
June 4th, 2011, 06:44 AM
hello i want to pause a thread when is not needed and resume it when i need it latter.
I tried using SuspendThread and ResumeThread but it behaves bugy when try to suspend and resume quickly, i been told that is not a good practice to use those functions if im not developing a debugger.
im not trying to sincronize multiple threads i dont have troubles with that critical sections and mutex works just fine.
i want to lock the thread so i could save system resources and resume when i need it.
i been trying to use WaitForSingleObject but it "Locks" only when another thread obtains the mutex but i want to be able to lock the thread form it self.
something like
while(Lock==true){
Sleep(50);
}
if i set the Lock to false from another thread this thread would resume. and pick another job.
am i able to get this functionality by using WaitForSingleObject?
I tried using SuspendThread and ResumeThread but it behaves bugy when try to suspend and resume quickly, i been told that is not a good practice to use those functions if im not developing a debugger.
im not trying to sincronize multiple threads i dont have troubles with that critical sections and mutex works just fine.
i want to lock the thread so i could save system resources and resume when i need it.
i been trying to use WaitForSingleObject but it "Locks" only when another thread obtains the mutex but i want to be able to lock the thread form it self.
something like
while(Lock==true){
Sleep(50);
}
if i set the Lock to false from another thread this thread would resume. and pick another job.
am i able to get this functionality by using WaitForSingleObject?