visual studio - C++ function Sleep() executes before piece of code -


i work in visual studio c++, windows form app. try paint button red, wait 3 seconds , paint blue.

button1->backcolor = system::drawing::color::darkred; sleep(3000); button1->backcolor = system::drawing::color::cornflowerblue; 

however, sleep() functions executes before first line (painting red). program starts waiting 3 seconds , after time paints button blue. seems painting red piece of code doesn't have time execute. individually, painting red works fine. i've tried other delay solutions also. example:

int wait = clock() + 2 * clocks_per_sec; while (clock() < wait) {} 

it seems issue in visual studio c++, because sleep() function have worked in code::blocks console script. have ideas of solution?

since button window can invalidate before calling sleep().
what invalidate,update methods in vc++


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -