This detection code has begun throwing ThreadAbortExceptions intermittently since we upgraded from Ranorex 3.0.2 to 3.2.0. It appears to be stemming from our use of the Ranorex Host.Local.TryFindSingle() method in our in TryWaitForForm() library method.
Our test machines are running Windows 7 32-bit on .NET 3.5.1
I have attached Ranorex Logs of the machines that experience this Exception, as well as the relevant script code.
The library method from which the exception throws:
Code: Select all
/// <summary>
/// Waits for a form to appear.
/// </summary>
/// <param name="rxPath">the Ranorex path to the form</param>
/// <param name="debugText">the debug text for the form name to show</param>
/// <param name="timeOut">the amount of time to wait for in seconds</param>
/// <param name="form">a reference to a form that is set if found (null if not)</param>
/// <returns>True if the form is found within the timeout; false otherwise.</returns>
public static bool TryWaitForForm(string rxPath, string debugText, float timeOut, out Ranorex.Form form)
{
// Convert timeout to milliseconds
timeOut *= 1000;
Report.Debug("Waiting for " + debugText + " for " + timeOut + " milliseconds.");
// This method is wrapped with a version without the out parameter as well.
// This is also where the exception appears to be thrown.
return Host.Local.TryFindSingle(rxPath, (Duration) timeOut, out form);
}
Code: Select all
enum NoteworthyForms
{
None,
DeliveryLocation,
IssueQuantity,
ConcurrencyError,
SaveAs
}
struct KeyForm
{
public string Path { get; set; }
public string Name { get; set; }
public NoteworthyForms Value { get; set; }
}
/// <summary>
/// Issues items to stock.
/// </summary>
private void IssueItems()
{
Report.Success(CurrentMilitaryTime() + " Beginning to issue items...");
bool success = false;
List<KeyForm> priorityList = new List<KeyForm>
{
_FormDeliveryLocation
};
while (!success)
{
Report.Info(CurrentMilitaryTime() + " (Sub-Task) Acquiring/Issuing Parts.");
bool concErr = false;
bool saveAs = false;
SelectCreatedWO();
ClickObject(repo.FormMaintenanceProcessDetail.ButtonOK);
Report.Info(CurrentMilitaryTime() + " Clicked OK on the Maintenance Process Detail form.");
AcquireAndReceiveParts();
while (saveAs == false)
{
switch (DetectCurrentForm( priorityList ))
{
case NoteworthyForms.DeliveryLocation:
EnterDeliveryLocation();
priorityList = new List<KeyForm>
{
_FormIssueQuantityPrompt,
_FormDeliveryLocation
};
break;
case NoteworthyForms.IssueQuantity:
IssuePartsToWorkCenter();
priorityList = new List<KeyForm>
{
_FormIssueQuantityPrompt,
_FormConcurrencyError,
_FormDeliveryLocation,
_FormSaveAs
};
break;
case NoteworthyForms.ConcurrencyError:
concErr = true;
HandleConcurrencyErrors();
priorityList = new List<KeyForm>
{
_FormIssueQuantityPrompt,
_FormDeliveryLocation,
_FormSaveAs
};
break;
case NoteworthyForms.SaveAs:
saveAs = true;
break;
}
}
DontSaveReportToFile();
ClickOkOnSentToPrinterMessage();
// Determine the success of the acquisition.
success = !concErr;
ReportResultsToLog(success, concErr);
}
Report.Success(CurrentMilitaryTime() + " Done issuing items.");
}
/// <summary>
/// Determines which active form is up.
/// </summary>
/// <returns>An enumerated NoteworthyForm, based on what is seen.</returns>
private static NoteworthyForms DetectCurrentForm(IEnumerable<KeyForm> forms)
{
// Gives the method 3 sets of 3-second windows to detect a form within.
// The actual form found will be determined within 1/2 a second (500 ms).
for (int i = 0; i < 2; i++)
{
Delay.Seconds(_Phase2TimeOut);
foreach (KeyForm form in forms)
{
if (TryWaitForForm(form.Path, form.Name, 0.125f))
{
return form.Value;
}
}
}
return NoteworthyForms.None;
}