I have this loop in a class which is executed on a new background thread from my main UI :-
public bool WaitForWindow(string strClass, string strCaption, int iMaxSeconds, int iSet)
i = iSet;
if (i < iMaxSeconds * 2)
if (!GetWindow(strClass, strCaption,0))
WaitForWindow(strClass, strCaption, iMaxSeconds, i);
What I am trying to achieve is for my loop not to be indefinately looping so I test how many times it's looped * delay which relates roughly to the number of seconds I would like to keep testing for (iMaxSeconds).
The loop seems to perform find and the "return false" line is hit when the condition is not met within the time allowed but then the very next line it executes is back up to the "return true" even if the condition is not met.
eg. having stepped through the code with a iMaxSeconds set to 2 (ie loop 4 times) the final running order seems to be :-
!!!! - Any ideas why these four "return true" lines are being executed??