Ranorex

Ranorex Thread in a C# Windows Application

 
Post new topic   Reply to topic    Ranorex Forum Index -> General Questions
View previous topic :: View next topic  
Author Message
darkheart



Joined: 04 Mar 2008
Posts: 2

PostPosted: Tue Mar 04, 2008 6:11 am    Post subject: Ranorex Thread in a C# Windows Application
I have a windows application that's written in C# where I'm using a separate thread to read a large list of values from another window (SysListView32 custom control with 10,000+ elements).

I'm using a loop in the Ranorex thread that looks like the following:
Code: click into code to enlarge

int listsize = ParentElement.ChildCount;
Element ChildElement;
for (int i = 0; i < listsize; i++)
{
  ChildElement = null;
  do
  {
    ChildElement = ParentElement.GetChild(i);
    Thread.Sleep(32);
  }while (ChildElement == null);
 
  ListTable.Rows.Add(ChildElement.Name,
                     ChildElement.Description);   
}

The loop works fine (except for being very very slow) with one small quirk.
When the main window loses focus, the Ranorex thread stops reading elements until it retains focus.

Can anyone shed some light onto why this is happening and/or provide a work around solution.
Back to top
View user's profile Send private message
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 256

PostPosted: Tue Mar 04, 2008 12:11 pm    Post subject:
First to the focus problem:
In fact it is true that some controls require focus in order to read their elements. However, I just tried to reproduce that behavior with the windows explorer tree view, but I can't. It seems to be a speciality of the control you use.

Secondly, the speed problem:
Be sure to set the Element.StaticProperties property to true. That should speed up the getting the Name of an element by far.
The other thing is to replace the loop calling GetChild() by the FindChildren method:
Code: click into code to enlarge
Element[] Children = ParentElement.FindChildren(Role.OutlineItem);
foreach (Element ChildElement in Children)
{
    ListTable.Rows.Add(ChildElement.Name, ChildElement.Description);
}

Perhaps that also solves the focus problem, but I'm not sure of that Confused

Regards,
Alex
Ranorex Support Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> General Questions All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum