Quantcast
Channel: Windows Desktop Development for Accessibility and Automation forum
Viewing all articles
Browse latest Browse all 585

How to avoid automation freezing when application is hanging?

$
0
0

Situation:

If WPF or WinForms application hangs then UI Automation also hangs. Application can be freeze around 1 minute, but I need able to have access to UIAutomationClient for working with another application at this time.

So, I have Application A (WinForms) that can be freezed during 1 minute. I haveApplication B (WPF) that I need to use using automation tools whenApplication A is freezing. And I have Application C (Console Application) that keeps automation functionality for finding windows of other applications.

Parts of sample:

Application A freeze can be reproduced using an endless loop (infinite loop) during 1 minute. For example, I give the part of code below for the application button that should freeze for 1 minute:

private void button1_Click(object sender, EventArgs e)
{
     var counter = 0;
     while (true)
     {
          Thread.Sleep(100);

          counter++;
          if (counter > 600) // If counter == 600 then it means that 60 seconds has passed.
          {
               break;
          }
     }
}

Application B is simple WPF window without any controls.

Application C is using one main function that gives able to get windows:

var windows = AutomationElement.RootElement.FindAll(TreeScope.Children, Condition.TrueCondition);

---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------

Thanks in advance!


Viewing all articles
Browse latest Browse all 585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>