Can some one please explain why this loop never ‘breaks’ and goes on forever please? How do I tell the program to recheck the status? All I want to do is not progress until the status changes. Thanks
DispatcherOperation dis = null;
for (int i = 0; i < 2; i++)
{
updateTextBox(i.ToString());
dis = Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(delegate
{
//yes, do nothing at all!!
}
));
}
while(dis.Status != DispatcherOperationStatus.Completed)
{
}
If you’re doing this on the same thread as the dispatcher is meant to run on, your infinite, unyielding loop effectively shuts out the dispatcher from ever being able to dispatch the call. You should not loop like this anyway – at the very least put a Sleep in the loop.