I have a function like this (parent and formToBeShown are WinForms form instances):
if (parent == null)
while (!formToBeShown.IsDisposed)
Do();
else
while (!parent.IsDisposed && !formToBeShown.IsDisposed)
Do();
I find these extremely inelegant. I would love to have the Do function called only once. Or even better if I can incorporate all the condition in one while loop. Don’t know if I am having a brain fart, but I can not think of a way to achieve this. Some thoughts?
I think using below code, you can use while loop only once.