I have one dataTable and looping through the rows, for each row doing following -
1. First project interact with one internal website where I am filling one form based on data in row
2. Then Starting one activity passing parameters (data in row) from first project and ActivityStarted handled in second project where it opens and fill forms on another third party website (has wizard of 3 pages, result is on next page)
3. Taking the final result value from stage 2 and passing it back to first project where ActivityComplete event handled
4. Then filling the final result in one text box of first website
5. Then submit the form on first website to save the data
Now I must wait for stages 2,3,4,5 to complete before starting with new row in for loop.I tried all versions of Start activity method, but not getting the expected result. Sometime it halts the application(doing nothing), sometimes stage 5 get executed and form on first website get saved before getting the final result value from activity.
Which is the best way to wait the loop till first row get completely processed? Stage 5 must wait till activity started in stage 2 get completed and data returned and filled in text box on first website.
**Moderation Team has archived post**
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.
The problem will be that you will might be on one of the Activity threads. Since an activity cannot complete until all threads of the prior activity are completed, you would actually be waiting inside the prior activity. How about rather than looping, you just get the Nth row in the table and start your activities? Then, on the completion of activity 5, you start your process over again incrementing your row counter. Another method, since each activity is queued and cannot execute until the previous ones are finished, would be to simply start all the activities at once. They would execute in the order you started them with each one starting after the prior one finishes. You would need to add a check to the start of each to determine if the prior one was successful if you needed a way to not continue.
I have only one activity defined that opens third party website and get the result back. I think activity and automation are two separate things. In one file created event handler I pick up the excel, export the data to DataTable (referenced article is Excel How to). In event handler I am looping through the DataTable and calling private function that fills the data on first website, then that private function calls another private function that starts the activity.
Now here if I use StartNowAndWait/StartAndWait should work ideally as per description of these methods. But it shows inconsistent behavior. Sometime activity get triggered, sometime just it halts for waiting something, and sometime it goes directly to activity completed handler.
Here I am starting interaction using one predefined interactionKey (hardcoded interactionKey because there are no multiple interaction scenario) in OpenSpan.Runtime.RuntimeLoader.AllProjectStarted event. Here first time activity get started and for subsequent rows it causes problem to start activity. In debug mode sometime it runs fine. Sometime give trouble.
Posted: 5 years ago
Posted: 18 Apr 2017 12:45 EDT
Thomas Sasnett (ThomasSasnett)
Lead Robotics Architect
As long as you are not triggering the StartAndWait either inside of or off of one of the activity threads, then it should work as you described. Always remember that activities are queued, so that the next activity in the queue will not execute until all threads from the prior activity have been completed. Confusingly, this would include the thread calling StartAndWait. If this were being executed within an activity, it would always timeout because the queue would not move on to the activity you started until the current one finishes waiting for the next one to timeout.