Code: Select all
System.Threading.ThreadAbortException: Thread was being aborted.
at RanorexFramework.RFW.WaitForWindow(String WindowName, Int32 Timeout) in C:\Documents and Settings\Admin\My Documents\Visual Studio 2008\Projects\RanorexFramework\RanorexFramework\Class1.cs:line 5085
at RanorexFramework.RFW.ReportPrint(Form HDReportsForm, ReportPrintOptions MyReportPrintOptions, Boolean boolCloseReportsDialog) in C:\Documents and Settings\Admin\My Documents\Visual Studio 2008\Projects\RanorexFramework\RanorexFramework\Class1.cs:line 9155
Code: Select all
public static Ranorex.Form WaitForWindow(string WindowName, int Timeout)
{
Ranorex.Form HDForm = null;
Report.Debug("Waiting for window: " + WindowName);
try
{
HDForm = Host.Local.FindSingle("/form[@title='" + WindowName + "' or @controlname='" + WindowName + "']", Timeout * 1000);
HDForm.Activate();
Thread.Sleep(1000);
return HDForm;
}
catch (RanorexException e)
{
try
{
Thread.Sleep(5000);
HDForm = Host.Local.FindSingle("/form[@title='" + WindowName + "' or @controlname='" + WindowName + "']", (Timeout * 2) * 1000);
HDForm.Activate();
Thread.Sleep(1000);
return HDForm;
}
catch (RanorexException ex)
{
Report.Debug("Unable to find window: " + WindowName);
return null; //THIS IS LINE 5085
}
}
} //End WaitForWindow
See below for line 9155:
Code: Select all
Ranorex.Form HDGeneratingReport = RFW.WaitForWindow("ProgressBarForm", 4);
I have two threads running in my automation tests. The first, main thread is the main testing thread and is marked with STAThread.
The second thread is created by the main thread to check for unhandled exceptions that may be thrown by the AUT. You guys there helped me write this one.
Code: Select all
public class Worker
{
Thread mainThread = null;
public Thread MainThread
{
set { mainThread = value; }
}
[STAThread]
public void ThreadTask()
{
try
{
int i = 0;
while (i == 0)
{
foreach (Ranorex.Form form in Host.Local.Find<Ranorex.Form>("/form[@title='Unhandled Application Thread Exception']"))
{
if (form.Visible && form.Enabled)
{
//Found Exception
Report.Failure("AUT Unhandled Application Thread Exception Detected.");
Report.Failure("Stopping all test threads.");
Report.Screenshot();
i++;
}
}
foreach (Ranorex.Form form in Host.Local.Find<Ranorex.Form>("/form[@title~'MainInterface.exe - Application Error']"))
{
if (form.Visible && form.Enabled)
{
//Found Exception
Report.Failure("Application Error Detected.");
Report.Failure("Stopping all test threads.");
Report.Screenshot();
i++;
}
}
Thread.Sleep(1000);
}
//Throw Exception to the Main Thread
if (mainThread != null)
mainThread.Abort("SUTAbort");
}
catch
{
}
}
}