I have a case that need embed a background sleep in a for loop. is there any way to do it without breakout the shape of for loop?
for (;;)
{
Dosomething();
Thread.Sleep(5000); // this blocks the UI thread, hope to find someway to sleep in background
}
-------------edited--------------
in Dosomething(), there is some UI thread operations like listBoxA.width += 5 (without dispatcher); Here the UI doesn't refresh until all the loop finishes. the reason I want to use Sleep is I want to see the UI refresh each Dosomething is executed, like a animation.