Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
4.67/5 (3 votes)
See more:
I wrote multi-threaded Excel C API code in Excel 2003 (before official multi-threading support) that puts a thread to sleep while it waits for jobs to be added whenever the thread is not busy. However, I seem to get a memory error when I put the thread to sleep with the following code

C++
boost::this_thread::sleep(boost::posix_time::milliseconds(100))


Is there a good alternative that I can utilize that won't utilize the CPU like an infinite loop would?

Note that I cannot utilize CLR directly in my add-in due to incompatibility issues. I could however reference a CLR dll, but I would prefer not to. I've found mixing CLR and BOOST sometimes leaks memory.
Posted
Updated 14-Jun-11 3:12am
v2

1 solution

WaitForSingleObject() could be a viable alternative, or Sleep() that is in the WinAPI.
 
Share this answer
 
Comments
T2102 14-Jun-11 9:33am    
Thanks, that did the trick
Albert Holguin 14-Jun-11 9:34am    
no prob :)
Sergey Alexandrovich Kryukov 14-Jun-11 11:23am    
Sure, a 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900