Need help with 'The window was destroyed during method execution'
- 7 years ago
What it sounds like is that, while the FindChildEx returns the object, something is still process on the page that destroys and, potentially, recreates the object. This is a standard problem in the world of Ajax and other such client side code execution. You might need to add different code to detect that the page has completely refreshed, including all client side execution, before you do your Find calls.
What the error means, FYI, has to do with object handles. So, the FindChildEx returns an object with a handle... that handle gets destroyed and a new one gets created. So, to us, the user, it all looks seemless. But behind the scenes, the tool no longer has a hook into the object. So, you need to make the tool wait longer before doing the FindChildEx. A hard coded delay is a start.... but 300 milliseconds is probably not long enough. I'd actually try that method but bump the delay up to 30000 milliseconds JUST as a diagnostic to make sure that waiting longer will fix the problem. If a longer delay fixes the problem, then you need to make your code "smarter".