Posted: 30 Jul 2018 9:05 EDT Last activity: 28 Dec 2018 15:43 EST
How to find and save a Thread details and then kill that thread on user action
Hi, I want to find and save current running thread details into variables and then on user action like on click of a button, I want to kill that previous thread. The main reason for this is.. one of the application that we are automating is very slow and it hangs few times and it runs in the background. If the user feels that it been hanging there for a while, there should be a way to kill that previous thread and start the process again. Can anyone Please let me know how to achieve this using Pega Robotics. Thanks,
This would require C# on your part as it is not available within the product. If you are simply looking to terminate a specific adapter, then you can do that by calling Stop on the adapter. You can also use the static method Process.GetProcessesByName to locate a specific process and Kill it.
Thanks for the response. In my scenario I wanted to provide an option to the user to immediately halt the execution at that instance without even completing the execution of the current step. for e.g. when a user starts processing a card by clicking on start process, automation has to complete 12 steps and when user realizes at step 3 that this is not the correct card to be processed, then we should be able to provide a button to the user to halt the automation at that instance without even completing step 3. Please let me know if there is any way we can kill that thread and initiate a new one or anything similar to this approach.
In your case, Considering every step of the 12 Step process as separate automation, we can proceed or Stop that particular step using a Flag, which is set only when the user clicks Stop Button.
The execution flow of First Button Automation and Stop Button Automation should be Asynchronous. If it single Project, using GC boolean flag. If it multiple project solution, use the Global Dictionary boolean variable.
This functionality can be implemented using an activity. Once you start an activity, you have the ability to cancel an activity. The StartActivity method returns a value that you can then pass to the CancelActivity method of the Interaction Manager component. Cancelling an activity will stop the automation at the next execution path.