Posted: 30 Aug 2019 11:02 EDT Last activity: 5 Sep 2019 9:07 EDT
Waiting on one of two events
I have the situation where when I submit a form on a web application the page is either refreshed or closed. I'd like to be able to wait on either the Element Changed or Destroyed events. Is there some way to do a Wait Any style on Events?
Create an automation to respond to these events and when fired, have them call SignalAll (I use SignalAll, but in this case it won't matter if you used SignalOne since you'll only ever be waiting on the signal in one place).
In your automation that is triggering the events simply call Wait on the Signal.
It will return true if either of the events happen during the timeout period.
It will return false if the events do not call it.
Here's a quick example. It doesn't use an adapter and instead uses a windows form, but you can see the idea of how it is used. The click events from the buttons could be replaced with adapter events (like destroyed, or create, or TextChanged, etc...).
When you call SignalOne only the first automation that is "waiting" (has called the Wait method of the Signal) will return True. If you have a use case where you have multiple places waiting on the signal at once, then use SignalOne to only allow the first one to return while the others continue waiting. SignalAll will allow all to return. Since you are only waiting in one place, either will work.