Upgraded to Ranorex 3.2.0 and ThreadAbortException

Bug reports.
argray
Posts: 4
Joined: Thu Jan 05, 2012 11:30 pm

Upgraded to Ranorex 3.2.0 and ThreadAbortException

Post by argray » Fri Jan 06, 2012 3:41 pm

Our company has a test script that contains code to detect and handle any one of four possible sub-forms that may display, based upon error handling and other application logic. This means that the forms may appear at any time or in any order at this point in the script.

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);
    }
The script using our TryWaitForForm library method:

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;
    }
 
Note: Unlike Ciege's script from this issue for Ranorex 2.2.2, we do not use a Watchdog thread to monitor the script for unhandled exceptions.
Attachments
STA135 (Automation24).zip
(882.82 KiB) Downloaded 197 times
STA110 (Automation4).zip
(849.95 KiB) Downloaded 190 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Upgraded to Ranorex 3.2.0 and ThreadAbortException

Post by Support Team » Mon Jan 09, 2012 6:12 pm

argray wrote:Note: Unlike Ciege's script from this issue for Ranorex 2.2.2, we do not use a Watchdog thread to monitor the script for unhandled exceptions.
We did not change anything with respect to that issue from 3.0.2 to 3.2.0. Actually, we did not change anything in the base functionality of the Find/FindSingle/TryFindSingle methods. If that issue has been introduced between 3.0.2 and 3.2.0, then it seems to be a side effect from new functionality or newly supported technologies.
  • Do these ThreadAbortExceptions happen only for specific controls, i.e. when searching for a specific RanoreXPath or when a specific application/form is open?
  • Do you have code using Thread.Abort or some other technique to abort the current process inside your test?
  • How is this test invoked? Is it run manually, by a scheduler, or a continuous integration system?
Regards,
Alex
Ranorex Team
.
Image

argray
Posts: 4
Joined: Thu Jan 05, 2012 11:30 pm

Re: Upgraded to Ranorex 3.2.0 and ThreadAbortException

Post by argray » Fri Jan 13, 2012 6:55 pm

To answer the questions:
  • Do these ThreadAbortExceptions happen only for specific controls, i.e. when searching for a specific RanoreXPath or when a specific application/form is open?
    No - this issue happens intermittently during the execution of the posted code.
  • Do you have code using Thread.Abort or some other technique to abort the current process inside your test?
    No - we do no thread manipulation whatsoever.
  • How is this test invoked? Is it run manually, by a scheduler, or a continuous integration system?
    We have a separate 'sequence' program that allows us run tests in a specified order.
We reverted our lab from 3.2.0 to 3.0.2 and still encountered this issue. For the time being, we're investigating the external environment of our test to see if something outside of Ranorex is causing this issue.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Upgraded to Ranorex 3.2.0 and ThreadAbortException

Post by Support Team » Mon Jan 16, 2012 5:40 pm

argray wrote:We have a separate 'sequence' program that allows us run tests in a specified order.
Does this "sequence" problem us timeouts that abort the execution if it takes longer then a specified time?
argray wrote: For the time being, we're investigating the external environment of our test to see if something outside of Ranorex is causing this issue.
Has anything else changed in your environment? Since you did not get these exception before, did you?

Regards,
Alex
Ranorex Team
.
Image

argray
Posts: 4
Joined: Thu Jan 05, 2012 11:30 pm

Re: Upgraded to Ranorex 3.2.0 and ThreadAbortException

Post by argray » Thu Feb 09, 2012 11:40 pm

Support Team wrote:Does this "Sequencer" cause timeouts that abort the execution if it takes longer than a specified time?
No.
Support Team wrote:Has anything else changed in your environment? Since you did not get these exception before, did you?
We are still investigating. At the moment, our investigations are leading us to believe that the issue does not lie in Ranorex.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Upgraded to Ranorex 3.2.0 and ThreadAbortException

Post by Support Team » Fri Feb 10, 2012 9:35 am

Thank you for your response! Please, keep us posted about the outcome of your investigations. Thanks!

Regards,
Alex
Ranorex Team
.
Image